Changeset 152 in pacpusframework for branches/2.0-beta1/include/Pacpus/kernel/ComponentBase.h
- Timestamp:
- 08/01/13 10:45:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.