-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathflowmgr.h
100 lines (75 loc) · 2.95 KB
/
flowmgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef _FLOWMGR_H
#define _FLOWMGR_H
#include "auxil.h"
#include "dsp.h"
#include "flow.h"
#include "dpeflow.h"
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <signal.h>
#define NPOS size_t(-1)
#define FlowFnt(T,CONST) \
int T(const std::string& key)CONST{ \
size_t idx = getFlowIdx (key); \
return (idx == NPOS)?-1:T(idx); \
}
#define RegFlow(TYPE,CNAME,M,NAME,DES) \
class CNAME: public Registrar{ \
public: \
CNAME(){} \
~CNAME(){} \
std::string get_name ()const{return NAME;} \
std::string get_desc ()const{return DES;} \
bool match(const std::string& cmd)const{ \
return (auxil::strcmpi(NAME,cmd,M) == 0); \
} \
Flow* createFlow()const{ \
return new dsp::TYPE; \
} \
}
class dsp::FlowMgr {
using FlowIdent = std::pair<dsp::Flow*,std::string>;
std::vector<FlowIdent> _flowlist;
std::map<std::string,size_t> _alias;
FlowMgr (const FlowMgr&);
Flow* getFlowPtr (const size_t& idx)const;
int loadFlow (const size_t& , const char* = nullptr) const;
int setParam (const size_t&,const std::string&,const std::string&,const std::string&)const;
int listOutput (const size_t&,const std::string&,const std::string&)const;
int destroyFlow (const std::size_t&);
int startFlow (const std::size_t&)const;
int stopFlow (const std::size_t&)const;
public:
FlowMgr();
~FlowMgr();
int createFlow (const std::string&, const std::string& = "");
int loadFlow (const std::string& key, const char* = nullptr) const;
size_t getFlowIdx (const std::string&) const;
void addAlias (const std::string& key,const size_t& value);
void listAlias () const;
void listFlow () const;
void flowType () const;
int setParam (const std::string&,const std::string&,const std::string&,const std::string&)const;
int listOutput (const std::string&,const std::string&,const std::string&)const;
FlowFnt (destroyFlow, );
FlowFnt (startFlow, const);
FlowFnt (stopFlow, const);
size_t EmergencyStop()const;
private:
class Registrar;
std::vector<Registrar*> _regis;
class Registrar {
protected:
Registrar(){}
public:
virtual ~Registrar() = 0;
virtual Flow* createFlow() const = 0;
virtual std::string get_name() const = 0;
virtual std::string get_desc() const = 0;
virtual bool match(const std::string& cmd) const = 0;
};
RegFlow(DPEFlow, DPE , 3 ,"DPE" ,"Direct Position Estimation Flow");
};
#endif