Changeset 152 in pacpusframework for branches/2.0-beta1/include
- Timestamp:
- Aug 1, 2013, 10:45:50 AM (11 years ago)
- Location:
- branches/2.0-beta1/include/Pacpus
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/DbitePlayer/DbtPlyEngine.h
r89 r152 91 91 92 92 protected: 93 virtual void addInputs(); 94 virtual void addOutputs(); 95 93 96 /// @todo Documentation 94 97 virtual void startActivity(); -
branches/2.0-beta1/include/Pacpus/DbitePlayer/DbtPlyTrigger.h
r89 r152 55 55 56 56 protected: 57 virtual void addInputs(); 58 virtual void addOutputs(); 59 57 60 /// @todo Documentation 58 61 virtual void startActivity(); -
branches/2.0-beta1/include/Pacpus/DbitePlayer/DbtPlyUserInterface.h
r89 r152 73 73 /// Displays the current time of the player. 74 74 void displayTime(road_time_t time); 75 76 protected: 77 virtual void addInputs(); 78 virtual void addOutputs(); 75 79 76 80 private: -
branches/2.0-beta1/include/Pacpus/PacpusTools/PacpusSerialPort.h
r122 r152 20 20 namespace pacpus { 21 21 22 class PacpusSerialPort : public QObject, public ComponentBase 22 class PacpusSerialPort 23 : public QObject 24 , public ComponentBase 23 25 { 24 26 Q_OBJECT 25 27 26 28 public: 27 28 typedef enum { ASCII, BINARY } DataMode; 29 typedef enum { 30 ASCII, 31 BINARY 32 } DataMode; 29 33 30 34 PacpusSerialPort(QString name); … … 36 40 ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config); 37 41 38 v oid addInput();39 v oid addOutput();42 virtual void addInputs(); 43 virtual void addOutputs(); 40 44 void processInputFrame(const QByteArray &); 41 45 42 private Q_SLOTS 46 private Q_SLOTS: 43 47 void readData(); 44 48 45 49 private: 46 47 50 QThread thread_; 48 51 … … 68 71 69 72 bool log; 70 71 72 73 }; 73 74 -
branches/2.0-beta1/include/Pacpus/kernel/ComponentBase.h
r138 r152 38 38 class ComponentManager; 39 39 40 template <typename T, class C> 41 class InputInterface; 42 43 template <typename T, class C> 44 class OutputInterface; 45 40 46 /** ComponentBase 41 47 * @brief Base class of a Pacpus component. … … 44 50 { 45 51 friend class ComponentManager; 52 46 53 public: 47 54 /** … … 87 94 * @return Name of the component. 88 95 */ 96 QString name() const; 89 97 QString getName() const; 90 98 91 InputInterfaceBase * getInput(QString ) const;92 93 OutputInterfaceBase * getOutput(QString ) const;99 InputInterfaceBase * getInput(QString name) const; 100 101 OutputInterfaceBase * getOutput(QString name) const; 94 102 95 103 protected: … … 115 123 // virtual QString getType() = 0; 116 124 117 virtual void addInput(); 118 119 virtual void addOutput(); 125 virtual void addInputs() = 0; 126 virtual void addOutputs() = 0; 127 128 protected: 129 typedef QMap<QString, InputInterfaceBase *> InputsMap; 130 typedef QMap<QString, OutputInterfaceBase *> OutputsMap; 131 132 // TODO: use std::function<void (const DataType &)> 133 // TODO: use std::mem_fun<void (const DataType &)> 134 template <typename DataType, class ComponentType, typename Function> 135 void addInput(const char * name, Function function) 136 { 137 typedef InputInterface<DataType, ComponentType> InputType; 138 InputType * connection = new InputType(name, dynamic_cast<ComponentType *>(this), function); 139 inputs().insert(name, connection); 140 } 141 142 template <typename DataType, class ComponentType> 143 void addOutput(const char * name) 144 { 145 typedef OutputInterface<DataType, ComponentType> OutputType; 146 OutputType * connection = new OutputType(name, dynamic_cast<ComponentType *>(this)); 147 outputs().insert(name, connection); 148 } 149 150 template <typename DataType, class ComponentType> 151 InputInterface<DataType, ComponentType> * 152 getTypedInput(const char * name) const 153 { 154 return dynamic_cast<InputInterface<DataType, ComponentType> *>(getInput(name)); 155 } 156 157 template <typename DataType, class ComponentType> 158 OutputInterface<DataType, ComponentType> * 159 getTypedOutput(const char * name) const 160 { 161 return dynamic_cast<OutputInterface<DataType, ComponentType> *>(getOutput(name)); 162 } 163 164 bool isActive() const; 165 void setActive(bool isActive); 166 bool isRecording() const; 167 void setRecording(bool isRecording); 168 169 InputsMap & inputs(); 170 const InputsMap & inputs() const; 171 OutputsMap & outputs(); 172 const OutputsMap & outputs() const; 173 174 COMPONENT_CONFIGURATION configurationState() const; 175 void setConfigurationState(COMPONENT_CONFIGURATION state); 176 177 const XmlComponentConfig xmlParameters() const; 120 178 121 protected:122 /// The XML node that is got in the configureComponent method123 XmlComponentConfig param;124 125 /// the name of the component. It is this one in the XML config file126 QString componentName;127 128 /// is the component is recording data?129 bool recording;130 131 /// provided for compatibility with old DBITE framework132 bool THREAD_ALIVE;133 134 /// is the component active?135 bool mIsActive;136 137 /// a pointer to the manager of components138 ComponentManager * mgr;139 140 QMap<QString, InputInterfaceBase *> input;141 QMap<QString, OutputInterfaceBase *> output;142 143 /// a pointer to an optional widget144 QWidget * ui;145 146 179 private: 147 180 /// called by the ComponentManager to start the component … … 151 184 int stopComponent(); 152 185 186 private: 187 /// The XML node that is got in the configureComponent method 188 XmlComponentConfig param; 189 190 /// the name of the component. It is this one in the XML config file 191 QString m_componentName; 192 193 /// is the component active? 194 volatile bool m_isActive; 195 196 /// is the component is recording data? 197 bool m_isRecording; 198 199 /// a pointer to the manager of components 200 ComponentManager * m_manager; 201 202 InputsMap m_inputs; 203 OutputsMap m_outputs; 204 205 /// a pointer to an optional widget 206 QWidget * m_ui; 207 153 208 /// store the state of the component 154 COMPONENT_STATE componentState_;209 COMPONENT_STATE m_componentState; 155 210 156 211 /// is the component configured (ie configureComponent method was called) 157 COMPONENT_CONFIGURATION configuration_;212 COMPONENT_CONFIGURATION m_configurationState; 158 213 }; 159 214 160 161 215 } // pacpus 162 216 -
branches/2.0-beta1/include/Pacpus/kernel/InputOutputBase.h
r148 r152 96 96 { 97 97 Q_OBJECT 98 98 99 protected: 99 100 InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0) -
branches/2.0-beta1/include/Pacpus/kernel/InputOutputInterface.h
r148 r152 12 12 #include <QByteArray> 13 13 14 #define ADD_INPUT(name,ComponentType, DataType, functionName) input.insert(name,new InputInterface<DataType,ComponentType> (name,this,&ComponentType::functionName)) 15 #define ADD_OUTPUT(name,ComponentType, DataType) output.insert(name,new OutputInterface<DataType,ComponentType> (name,this)) 16 17 #define GET_OUTPUT(name,ComponentType, DataType) dynamic_cast<OutputInterface<DataType,ComponentType> *> (output.value(name)) 18 #define GET_INPUT(name,ComponentType, DataType) dynamic_cast<InputInterface<DataType,ComponentType> *> (input.value(name)) 14 //#define ADD_INPUT(name, ComponentType, DataType, functionName) \ 15 // inputs().insert((name), new InputInterface<DataType, ComponentType> ((name), this, &ComponentType::functionName)) 16 //#define ADD_OUTPUT(name, ComponentType, DataType) \ 17 // outputs().insert((name), new OutputInterface<DataType, ComponentType> ((name), this)) 18 19 //#define GET_INPUT(name, ComponentType, DataType) \ 20 // dynamic_cast<InputInterface<DataType, ComponentType> *> (input.value(name)) 21 //#define GET_OUTPUT(name, ComponentType, DataType) \ 22 // dynamic_cast<OutputInterface<DataType, ComponentType> *> (output.value(name)) 19 23 20 24 namespace pacpus { 21 25 22 template < classT, class C>26 template <typename T, class C> 23 27 class InputInterface 24 28 : public InputInterfaceBase … … 26 30 public: 27 31 InputInterface(QString name, C * component, void (C::*m)(const T&)) 28 : InputInterfaceBase(name, component,component)32 : InputInterfaceBase(name, component, component) 29 33 , method(m) 30 34 {} … … 140 144 }; 141 145 142 template < classT, class C>146 template <typename T, class C> 143 147 class OutputInterface : public OutputInterfaceBase 144 148 {
Note:
See TracChangeset
for help on using the changeset viewer.