Changeset 288 in pacpusframework
- Timestamp:
- Mar 26, 2014, 9:27:30 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/ProducerConsumerExample/ConsumerExample.cpp
r272 r288 10 10 DECLARE_STATIC_LOGGER("pacpus.cityvip.test.ConsumerExample"); 11 11 12 /// Construct the factory 13 static ComponentFactory<ConsumerExample> sFactory("ConsumerExample"); 12 PACPUS_REGISTER_COMPONENT(ConsumerExample); 14 13 15 14 ConsumerExample::ConsumerExample(QString name) -
trunk/examples/ProducerConsumerExample/ConsumerExample.h
r176 r288 10 10 #include <string> 11 11 12 namespace pacpus { 12 namespace pacpus 13 { 13 14 14 15 class PRODUCERCONSUMEREXAMPLE_API ConsumerExample 15 16 16 : public QObject 17 , public ComponentBase 17 18 { 18 19 Q_OBJECT -
trunk/examples/ProducerConsumerExample/ProducerExample.cpp
r202 r288 12 12 DECLARE_STATIC_LOGGER("pacpus.cityvip.test.ProducerExample"); 13 13 14 /// Construct the factory 15 static ComponentFactory<ProducerExample> sFactory("ProducerExample"); 14 PACPUS_REGISTER_COMPONENT(ProducerExample); 16 15 17 16 static const char * outputFileName = "producer.txt"; -
trunk/include/Pacpus/DbitePlayer/DbtPlyFileManager.h
r181 r288 97 97 98 98 /// a pointer on the player engine 99 DbtPlyEngine *mEngine;99 boost::shared_ptr<DbtPlyEngine> mEngine; 100 100 101 101 QStringList getDbiteFilenameList() const; -
trunk/include/Pacpus/DbitePlayer/DbtPlyTrigger.h
r152 r288 64 64 65 65 private: 66 DbtPlyEngine *mEngine;66 boost::shared_ptr<DbtPlyEngine> mEngine; 67 67 }; 68 68 -
trunk/include/Pacpus/DbitePlayer/DbtPlyUserInterface.h
r152 r288 99 99 100 100 private: 101 DbtPlyEngine *mEngine;101 boost::shared_ptr<DbtPlyEngine> mEngine; 102 102 103 103 QWidget * wTel_ ; -
trunk/include/Pacpus/kernel/ComponentBase.h
r286 r288 23 23 #define DEF_PACPUS_COMPONENTBASE_H 24 24 25 #include <Pacpus/kernel/ComponentManager.h>25 //#include <Pacpus/kernel/ComponentManager.h> 26 26 #include <Pacpus/kernel/InputOutputBase.h> 27 27 // InputOutputInterface.h must be included, otherwise we could not use addInput, addOutput template methods … … 33 33 #include <boost/program_options/options_description.hpp> 34 34 #include <boost/program_options/value_semantic.hpp> 35 #include <QMap> 35 36 #include <QString> 36 #include <QMap>37 37 #include <string> 38 38 … … 52 52 namespace pacpus 53 53 { 54 55 class ComponentBase; 54 56 55 57 class ComponentManager; … … 91 93 /// Ctor of ComponentBase. 92 94 /// @param name Name of your component. 93 ComponentBase( const QString& name);95 ComponentBase(QString const& name); 94 96 95 97 /// Dtor of ComponentBase. … … 195 197 std::string mName; 196 198 std::string mTypeName; 197 199 //QThread mThread; 200 198 201 /// Whether to display or not the graphical interface (GUI) 199 202 bool hasGui() const; -
trunk/include/Pacpus/kernel/ComponentFactory.h
r89 r288 16 16 #define DEF_PACPUS_COMPONENTFACTORY_H 17 17 18 #include <cassert> 19 20 //#include <boost/static_assert.hpp> 21 //#include <boost/type_traits/is_base_of.hpp> 18 #include <boost/assert.hpp> 19 #include <boost/static_assert.hpp> 20 #include <boost/type_traits/is_base_of.hpp> 22 21 23 22 #include <Pacpus/kernel/ComponentFactoryBase.h> … … 37 36 static pacpus::ComponentFactory<className> sFactory(factoryName) 38 37 39 namespace pacpus { 38 #define PACPUS_REGISTER_COMPONENT(Class) \ 39 static pacpus::ComponentFactory<Class> sFactory(#Class) 40 41 namespace pacpus 42 { 40 43 41 44 /// Use it to interface your components with the application. … … 47 50 : public ComponentFactoryBase 48 51 { 49 //static_assert(,"T must inherit from ComponentBase")50 // BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ComponentBase, T>::value), "T must inherit from ComponentBase"); 52 BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ComponentBase, T>::value), "component T must inherit from ComponentBase"); 53 51 54 public: 52 55 /** Ctor of ComponentFactory, initialize the factory of the components of type @em T. 53 56 * @param type Name of the type of the components. 54 57 */ 55 ComponentFactory( const QString& type);58 ComponentFactory(QString const& type); 56 59 57 60 /** Dtor of ComponentFactory. */ … … 61 64 * @return Name of the type of the components. 62 65 */ 63 const QString& getType() const;66 QString const& getType() const; 64 67 65 68 protected: 66 virtual Component Base* instantiateComponent(const QString& name);67 69 virtual ComponentSharedPointer instantiateComponent(QString const& name); 70 68 71 private: 69 72 QString mType; … … 71 74 72 75 template <typename T> 73 ComponentFactory<T>::ComponentFactory( const QString& type)74 : mType(type)76 ComponentFactory<T>::ComponentFactory(QString const& type) 77 : mType(type) 75 78 { 76 assert(!type.isEmpty());79 BOOST_ASSERT(!type.isEmpty()); 77 80 addFactory(this, mType); 78 81 } … … 84 87 85 88 template <typename T> 86 const QString& ComponentFactory<T>::getType() const89 QString const& ComponentFactory<T>::getType() const 87 90 { 88 91 return mType; … … 90 93 91 94 template<typename T> 92 Component Base* ComponentFactory<T>::instantiateComponent(const QString& name)95 ComponentSharedPointer ComponentFactory<T>::instantiateComponent(QString const& name) 93 96 { 94 return new T(name);97 return ComponentSharedPointer(new T(name)); 95 98 } 96 99 97 } // pacpus100 } // namespace pacpus 98 101 99 102 #endif // DEF_PACPUS_DBITEEXCEPTION_H -
trunk/include/Pacpus/kernel/ComponentFactoryBase.h
r196 r288 18 18 #include <Pacpus/kernel/PacpusLibConfig.h> 19 19 20 #include <boost/shared_ptr.hpp> 21 //#include <boost/weak_ptr.hpp> 22 20 23 class QString; 21 24 22 namespace pacpus { 25 namespace pacpus 26 { 27 28 class ComponentBase; 29 30 typedef boost::shared_ptr<ComponentBase> ComponentSharedPointer; 31 //typedef boost::weak_ptr<ComponentBase> ComponentWeakPointer; 23 32 24 33 class ComponentManager; 25 class ComponentBase;26 34 27 35 /** ComponentFactoryBase … … 31 39 { 32 40 friend class ComponentManager; 41 33 42 public: 34 43 /** Ctor of ComponentFactoryBase. */ … … 42 51 * @return Pointer on the newly created component, you become the owner of its lifetime. 43 52 */ 44 virtual Component Base * instantiateComponent(const QString& name) = 0;53 virtual ComponentSharedPointer instantiateComponent(QString const& name) = 0; 45 54 46 55 /** Register a new factory. … … 48 57 * @param type Name of the type created by the factory. 49 58 */ 50 void addFactory(ComponentFactoryBase* addr, const QString& type);59 void addFactory(ComponentFactoryBase* addr, QString const& type); 51 60 52 61 /** Add a new component. 53 62 * @param name Name of the new component. 54 63 */ 55 void addComponent(const QString& name);64 void createComponent(QString const& name); 56 65 57 66 private: -
trunk/include/Pacpus/kernel/ComponentManager.h
r207 r288 28 28 #include <QPluginLoader> 29 29 30 namespace pacpus { 30 namespace pacpus 31 { 31 32 32 33 class ComponentBase; 33 34 34 35 /// @todo Documentation 35 typedef QMap<QString, Component Base *> ComponentMap;36 typedef QMap<QString, ComponentSharedPointer> ComponentMap; 36 37 /// @todo Documentation 37 typedef QMap<QString, ComponentFactoryBase *> FactoryMap;38 typedef QMap<QString, ComponentFactoryBase* > FactoryMap; 38 39 39 40 /// Singleton recording the components and managing them. … … 59 60 struct destroyer { 60 61 /// Invokes ComponentManager::destroy() method if @b mgr pointer is not null. 61 void operator()(ComponentManager 62 void operator()(ComponentManager* mgr) const 62 63 { 63 64 if (!mgr) { … … 72 73 * @return Number of components loaded by the manager. 73 74 */ 74 std::size_t loadComponents( const QString& file);75 std::size_t loadComponents(QString const& file); 75 76 76 77 /** Start all the components … … 83 84 * @return True if the component exists and has been started, otherwise false. 84 85 */ 85 bool start( const QString& component);86 bool start(QString const& component); 86 87 87 88 /** Stop all the components … … 94 95 * @return True if the component has been stopped, otherwise false. 95 96 */ 96 bool stop( const QString& component);97 bool stop(QString const& component); 97 98 98 99 /** Get a pointer to the component referred by @em name. … … 100 101 * @return Pointer to the component if it exists, otherwise @em NULL. 101 102 */ 102 Component Base* getComponent(const QString& name);103 ComponentSharedPointer getComponent(QString const& name); 103 104 104 105 /** Get the list of all the names of the component known by the manager. … … 111 112 * @return True if the plugin has been loaded, otherwise false. 112 113 */ 113 bool loadPlugin( const QString& filename);114 bool loadPlugin(QString const& filename); 114 115 115 116 private: 116 bool stop(Component Base*component) const;117 bool stop(ComponentSharedPointer component) const; 117 118 118 119 /// Create a new component of type 'type' and with the name 'name' 119 bool createComponent( const QString& type, const QString& name);120 bool createComponent(QString const& type, QString const& name); 120 121 121 bool checkComponent( const QString& componentName);122 bool checkComponentInput( const QString & componentName, const QString& inputName);123 bool checkComponentOutput( const QString & componentName, const QString& outputName);122 bool checkComponent(QString const& componentName); 123 bool checkComponentInput(QString const& componentName, QString const& inputName); 124 bool checkComponentOutput(QString const& componentName, QString const& outputName); 124 125 125 bool createConnection( const QString& type, const QString& name, const QString& , int );126 bool createConnection(QString const& type, QString const& name, QString const& , int ); 126 127 127 bool registerComponent(Component Base* addr, const QString& name);128 bool registerComponentFactory(ComponentFactoryBase* addr, const QString& type);128 bool registerComponent(ComponentSharedPointer addr, QString const& name); 129 bool registerComponentFactory(ComponentFactoryBase* addr, QString const& type); 129 130 130 bool unregisterComponent( const QString& name);131 bool unregisterComponentFactory( const QString& type);131 bool unregisterComponent(QString const& name); 132 bool unregisterComponentFactory(QString const& type); 132 133 133 134 // Allow 2 functions to access to private members of ComponentManager 134 friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString& type);135 friend void ComponentFactoryBase:: addComponent(const QString& name);135 friend void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type); 136 friend void ComponentFactoryBase::createComponent(QString const& name); 136 137 137 138 /// private constructor accessible only via static create() function -
trunk/include/Pacpus/kernel/XmlComponentConfig.h
r270 r288 35 35 * @param name Name of the ComponentFactory, by convention equal to class name. 36 36 */ 37 explicit XmlComponentConfig( const QString& name = QString::null);37 explicit XmlComponentConfig(QString const& name = QString::null); 38 38 39 39 /** Dtor of XmlComponentConfig. */ … … 45 45 * @param name Name of the property. 46 46 */ 47 void addProperty( const QString& name);47 void addProperty(QString const& name); 48 48 49 49 /** Delete a property from the XML. 50 50 * @return False if the property does not exist, false otherwise. 51 51 */ 52 int delProperty( const QString& name);52 int delProperty(QString const& name); 53 53 54 54 /** Get the value of a property. … … 57 57 * @return Value of the property, @em defaultValue otherwise. 58 58 */ 59 QString getProperty( const QString& name, const QString& defaultValue = QString::null) const;59 QString getProperty(QString const& name, QString const& defaultValue = QString::null) const; 60 60 61 61 /** Get the value of a property as a boolean. … … 64 64 * @return Value of the property, @em defaultValue otherwise. 65 65 */ 66 bool getBoolProperty( const QString& name, bool defaultValue = false) const;66 bool getBoolProperty(QString const& name, bool defaultValue = false) const; 67 67 68 68 /** Get the value of a property as an integer. … … 71 71 * @return Value of the property, @em defaultValue otherwise. 72 72 */ 73 int getIntProperty( const QString& name, int defaultValue = 0) const;73 int getIntProperty(QString const& name, int defaultValue = 0) const; 74 74 75 75 /** Get the value of a property as a double. … … 78 78 * @return Value of the property, @em defaultValue otherwise. 79 79 */ 80 double getDoubleProperty( const QString& name, double defaultValue = 0.0) const;80 double getDoubleProperty(QString const& name, double defaultValue = 0.0) const; 81 81 82 82 /** Set the value of a property. … … 84 84 * @param value Value to set. 85 85 */ 86 void setProperty( const QString& name, const QString& value);86 void setProperty(QString const& name, QString const& value); 87 87 88 88 /** Check if a property exists. … … 90 90 * @return True if the property exists, false otherwise. 91 91 */ 92 bool hasProperty( const QString& name) const;92 bool hasProperty(QString const& name) const; 93 93 94 94 public: -
trunk/include/Pacpus/kernel/XmlConfigFile.h
r197 r288 41 41 class PACPUSLIB_API XmlConfigFile 42 42 { 43 friend XmlComponentConfig::XmlComponentConfig( const QString&);43 friend XmlComponentConfig::XmlComponentConfig(QString const&); 44 44 friend class ComponentManager; 45 45 -
trunk/src/DBITEPlayerLib/DbtPlyEngine.cpp
r277 r288 10 10 #include <Pacpus/kernel/Log.h> 11 11 12 #include < cassert>12 #include <boost/assert.hpp> 13 13 #include <limits> 14 14 #include <QDir> … … 226 226 void DbtPlyEngine::playEvent() 227 227 { 228 using boost::dynamic_pointer_cast; 229 228 230 LOG_DEBUG("Clicked: play"); 229 231 230 232 // get user interface 231 233 ComponentManager * mgr = ComponentManager::getInstance(); 232 DbtPlyUserInterface * ui = dynamic_cast<DbtPlyUserInterface *>(mgr->getComponent("dbiteUserInterface"));233 assert(ui);234 boost::shared_ptr<DbtPlyUserInterface> ui = dynamic_pointer_cast<DbtPlyUserInterface>(mgr->getComponent("dbiteUserInterface")); 235 BOOST_ASSERT(ui); 234 236 // get time value from slider 235 237 lastTDbt_ = ui->getTime() + tDbtMin_; … … 268 270 void DbtPlyEngine::setState(DbtPlyEngineState * newState) 269 271 { 270 assert(newState);272 BOOST_ASSERT(newState); 271 273 LOG_DEBUG(mCurrentState->toString() << " => " << newState->toString()); 272 274 mCurrentState = newState; … … 284 286 mSpeed = kMaxSpeed; 285 287 } 286 assert(kMinSpeed <= mSpeed);287 assert(mSpeed <= kMaxSpeed);288 BOOST_ASSERT(kMinSpeed <= mSpeed); 289 BOOST_ASSERT(mSpeed <= kMaxSpeed); 288 290 LOG_INFO("event: Speed Up, speed = " << mSpeed); 289 291 Q_EMIT displayStateSig(mCurrentState, mSpeed); … … 296 298 mSpeed = kMinSpeed; 297 299 } 298 assert(kMinSpeed <= mSpeed);299 assert(mSpeed <= kMaxSpeed);300 BOOST_ASSERT(kMinSpeed <= mSpeed); 301 BOOST_ASSERT(mSpeed <= kMaxSpeed); 300 302 LOG_INFO("event: Speed Up, speed = " << mSpeed); 301 303 Q_EMIT displayStateSig(mCurrentState, mSpeed); … … 304 306 void DbtPlyEngine::reset() 305 307 { 308 using boost::dynamic_pointer_cast; 309 306 310 lastTNow_ = road_time(); 307 311 lastTDbt_ = tDbtMin_; … … 311 315 // get user interface 312 316 ComponentManager * mgr = ComponentManager::getInstance(); 313 DbtPlyUserInterface * ui = dynamic_cast<DbtPlyUserInterface *>(mgr->getComponent("dbiteUserInterface"));314 assert(ui);317 boost::shared_ptr<DbtPlyUserInterface> ui = dynamic_pointer_cast<DbtPlyUserInterface>(mgr->getComponent("dbiteUserInterface")); 318 BOOST_ASSERT(ui); 315 319 // reset time value of the slider 316 320 ui->resetTime(); -
trunk/src/DBITEPlayerLib/DbtPlyFileManager.cpp
r181 r288 67 67 ComponentBase::COMPONENT_CONFIGURATION DbtPlyFileManager::configureComponent(XmlComponentConfig config) 68 68 { 69 using boost::dynamic_pointer_cast; 70 69 71 ComponentManager * mgr = ComponentManager::getInstance(); 70 mEngine = static_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));71 if ( NULL == mEngine) {72 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 73 if (!mEngine) { 72 74 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 73 75 return CONFIGURED_FAILED; … … 81 83 // register the road_time_t type for the connection 82 84 qRegisterMetaType<road_time_t>("road_time_t"); 83 connect(mEngine , SIGNAL(play(road_time_t,road_time_t, bool)),85 connect(mEngine.get(), SIGNAL(play(road_time_t,road_time_t, bool)), 84 86 this, SLOT(playData(road_time_t,road_time_t, bool)), 85 87 Qt::DirectConnection); 86 88 connect(this, SIGNAL(tMinMaxIs(road_time_t,road_time_t )), 87 mEngine , SLOT(tMinMax(road_time_t, road_time_t)));88 connect(mEngine , SIGNAL(stopfile()),89 mEngine.get(), SLOT(tMinMax(road_time_t, road_time_t))); 90 connect(mEngine.get(), SIGNAL(stopfile()), 89 91 this, SLOT (beginfile())); 90 92 -
trunk/src/DBITEPlayerLib/DbtPlyTrigger.cpp
r152 r288 39 39 ComponentBase::COMPONENT_CONFIGURATION DbtPlyTrigger::configureComponent(XmlComponentConfig /*config*/) 40 40 { 41 using boost::dynamic_pointer_cast; 42 41 43 ComponentManager * mgr = ComponentManager::getInstance(); 42 44 // we get a pointer to the engine component 43 mEngine = dynamic_ cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));44 if ( NULL ==mEngine) {45 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 46 if (!mEngine) { 45 47 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 46 48 return CONFIGURED_FAILED; 47 49 } 48 50 connect(this, SIGNAL(triggerSig()), 49 mEngine ,SLOT(engReceiver()),51 mEngine.get(), SLOT(engReceiver()), 50 52 Qt::DirectConnection); 51 53 -
trunk/src/DBITEPlayerLib/DbtPlyUserInterface.cpp
r152 r288 61 61 ComponentBase::COMPONENT_CONFIGURATION DbtPlyUserInterface::configureComponent(XmlComponentConfig /*config*/) 62 62 { 63 using boost::dynamic_pointer_cast; 64 63 65 ComponentManager * mgr = ComponentManager::getInstance(); 64 mEngine = dynamic_ cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));65 if ( NULL ==mEngine) {66 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 67 if (!mEngine) { 66 68 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 67 69 return CONFIGURED_FAILED; … … 275 277 componentTableWidget->setItem(idx, 0, new QTableWidgetItem(componentName)); 276 278 277 ComponentBase * component = mgr->getComponent(componentName); 278 if (component) { 279 COMPONENT_STATE state = component->getState(); 280 281 QString stateString; 282 switch (state) { 283 case STOPPED: 284 stateString = tr("Stopped"); 285 break; 286 case NOT_MONITORED: 287 stateString = tr("Not monitored"); 288 break; 289 case MONITOR_OK: 290 stateString = tr("Monitor OK"); 291 break; 292 case MONITOR_NOK: 293 stateString = tr("Monitor wrong"); 294 break; 295 296 default: 297 stateString = tr("UNKNOWN"); 298 break; 299 } 300 componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString)); 301 302 // TODO: ADD component type and some detailed information (e.g. parameters) 303 //QString componentInfo = component->getDetails(); 304 //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo)); 279 ComponentSharedPointer component = mgr->getComponent(componentName); 280 if (!component) { 281 continue; 305 282 } 283 284 COMPONENT_STATE state = component->getState(); 285 286 QString stateString; 287 switch (state) { 288 case STOPPED: 289 stateString = tr("Stopped"); 290 break; 291 case NOT_MONITORED: 292 stateString = tr("Not monitored"); 293 break; 294 case MONITOR_OK: 295 stateString = tr("Monitor OK"); 296 break; 297 case MONITOR_NOK: 298 stateString = tr("Monitor wrong"); 299 break; 300 301 default: 302 stateString = tr("UNKNOWN"); 303 break; 304 } 305 componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString)); 306 307 // TODO: ADD component type and some detailed information (e.g. parameters) 308 //QString componentInfo = component->getDetails(); 309 //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo)); 306 310 } 307 311 } … … 309 313 void DbtPlyUserInterface::connectButtons() 310 314 { 315 // FIXME: use Qt5 connect style 311 316 connect(playBut, SIGNAL(clicked()), 312 mEngine , SLOT(playEvent()));317 mEngine.get(), SLOT(playEvent())); 313 318 connect(pauseBut, SIGNAL(clicked()), 314 mEngine , SLOT(pauseEvent()));319 mEngine.get(), SLOT(pauseEvent())); 315 320 connect(stopBut, SIGNAL(clicked()), 316 mEngine , SLOT(stopEvent()));321 mEngine.get(), SLOT(stopEvent())); 317 322 connect(speedUpBut, SIGNAL(clicked()), 318 mEngine , SLOT(speedUpEvent()));323 mEngine.get(), SLOT(speedUpEvent())); 319 324 connect(speedDownBut, SIGNAL(clicked()), 320 mEngine , SLOT(speedDownEvent()));325 mEngine.get(), SLOT(speedDownEvent())); 321 326 } 322 327 323 328 void DbtPlyUserInterface::connectDisplay() 324 329 { 325 connect(mEngine , SIGNAL(displayStateSig(DbtPlyEngineState *, float)),330 connect(mEngine.get(), SIGNAL(displayStateSig(DbtPlyEngineState *, float)), 326 331 this, SLOT(displayStateSlot(DbtPlyEngineState *, float))); 327 332 328 connect (mEngine , SIGNAL(timeMinMax(road_time_t, road_time_t)),333 connect (mEngine.get(), SIGNAL(timeMinMax(road_time_t, road_time_t)), 329 334 this, SLOT(displayMinMaxTime(road_time_t , road_time_t))); 330 connect (mEngine , SIGNAL(curReplayTime(road_time_t)),335 connect (mEngine.get(), SIGNAL(curReplayTime(road_time_t)), 331 336 this, SLOT(displayTime(road_time_t))); 332 337 connect (rev, SIGNAL(toggled(bool)), 333 mEngine , SLOT(changeDirection(bool)));338 mEngine.get(), SLOT(changeDirection(bool))); 334 339 } 335 340 … … 337 342 { 338 343 connect (timeSlider, SIGNAL(sliderPressed()), 339 mEngine , SLOT(pauseEvent()));344 mEngine.get(), SLOT(pauseEvent())); 340 345 connect (timeSlider, SIGNAL(sliderReleased()), 341 mEngine , SLOT(playEvent()));346 mEngine.get(), SLOT(playEvent())); 342 347 } 343 348 -
trunk/src/PacpusLib/ComponentBase.cpp
r286 r288 17 17 #include <boost/program_options/parsers.hpp> 18 18 #include <boost/program_options/variables_map.hpp> 19 #include <boost/thread/thread.hpp>19 //#include <boost/thread/thread.hpp> 20 20 #include <ostream> 21 21 #include <string> … … 77 77 DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase"); 78 78 79 ComponentBase::ComponentBase( const QString& componentName)79 ComponentBase::ComponentBase(QString const& componentName) 80 80 : m_componentName(componentName) 81 81 , m_isActive(false) … … 131 131 } 132 132 133 void ComponentBase::startComponentWithException(boost::exception_ptr& error)134 {135 try {136 startActivity();137 error = boost::exception_ptr();138 } catch (...) {139 error = boost::current_exception();140 }141 }142 143 void ComponentBase::startComponentInThread()144 {145 boost::exception_ptr error;146 boost::thread t(147 boost::bind(148 &ComponentBase::startComponentWithException,149 this,150 boost::ref(error)151 )152 );153 t.join();154 if (error) {155 try {156 boost::rethrow_exception(error);157 } catch (boost::exception& e) {158 LOG_FATAL("[" << getName() << "]" << "\tboost::exception thrown: " << boost::diagnostic_information(e));159 //throw;160 }161 }162 }133 //void ComponentBase::startComponentWithException(boost::exception_ptr& error) 134 //{ 135 // try { 136 // startActivity(); 137 // error = boost::exception_ptr(); 138 // } catch (...) { 139 // error = boost::current_exception(); 140 // } 141 //} 142 // 143 //void ComponentBase::startComponentInThread() 144 //{ 145 // boost::exception_ptr error; 146 // boost::thread t( 147 // boost::bind( 148 // &ComponentBase::startComponentWithException, 149 // this, 150 // boost::ref(error) 151 // ) 152 // ); 153 // t.join(); 154 // if (error) { 155 // try { 156 // boost::rethrow_exception(error); 157 // } catch (boost::exception& e) { 158 // LOG_FATAL("[" << getName() << "]" << "\tboost::exception thrown: " << boost::diagnostic_information(e)); 159 // //throw; 160 // } 161 // } 162 //} 163 163 164 164 int ComponentBase::startComponent() … … 170 170 171 171 setActive(true); 172 boost::thread worker(&ComponentBase::startComponentInThread, this); 173 //boost::thread worker(&ComponentBase::startActivity, this); 174 //startActivity(); 172 //boost::thread worker(&ComponentBase::startComponentInThread, this); 173 startActivity(); 174 //moveToThread(&mThread); 175 //mThread.start(); 175 176 return true; 176 177 } … … 185 186 setActive(false); 186 187 stopActivity(); 187 188 //QMetaObject::invokeMethod(&mThread, "quit"); 188 189 return true; 189 190 } -
trunk/src/PacpusLib/ComponentFactoryBase.cpp
r89 r288 10 10 #include <Pacpus/kernel/Log.h> 11 11 12 #include < cassert>12 #include <boost/assert.hpp> 13 13 #include <QString> 14 14 … … 23 23 // get the adress of the ComponentManager instance 24 24 mgr_ = ComponentManager::getInstance(); 25 BOOST_ASSERT(mgr_); 25 26 } 26 27 … … 30 31 } 31 32 32 void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, const QString& type)33 void ComponentFactoryBase::addFactory(ComponentFactoryBase* addr, QString const& type) 33 34 { 34 35 LOG_DEBUG("addFactory(type="<< type << ")"); 35 36 36 assert(mgr_);37 37 if (!mgr_->registerComponentFactory(addr, type)) { 38 38 /* … … 44 44 } 45 45 46 void ComponentFactoryBase:: addComponent(const QString& name)46 void ComponentFactoryBase::createComponent(QString const& name) 47 47 { 48 48 LOG_DEBUG("addComponent(" << name << ")"); 49 49 50 // FIXME: instantiated component is never deleted! 51 // who should do it? ComponentManager? 52 ComponentBase * addr = instantiateComponent(name); 53 assert(mgr_); 54 if (!mgr_->registerComponent(addr, name)) { 55 delete addr; 56 addr = NULL; 57 } 50 ComponentSharedPointer component = instantiateComponent(name); 51 mgr_->registerComponent(component, name); 58 52 } -
trunk/src/PacpusLib/ComponentManager.cpp
r277 r288 125 125 } 126 126 127 bool ComponentManager::registerComponentFactory(ComponentFactoryBase* addr, const QString& type)127 bool ComponentManager::registerComponentFactory(ComponentFactoryBase* addr, QString const& type) 128 128 { 129 129 LOG_TRACE("registerComponentFactory(type="<< type << ")"); … … 141 141 } 142 142 143 bool ComponentManager::unregisterComponentFactory( const QString& type)143 bool ComponentManager::unregisterComponentFactory(QString const& type) 144 144 { 145 145 LOG_TRACE("unregisterComponentFactory(type="<< type << ")"); … … 156 156 } 157 157 158 bool ComponentManager::registerComponent( ComponentBase* addr, const QString& name)158 bool ComponentManager::registerComponent(boost::shared_ptr<ComponentBase> addr, QString const& name) 159 159 { 160 160 LOG_TRACE("registerComponent(name="<< name << ")"); … … 171 171 } 172 172 173 bool ComponentManager::unregisterComponent( const QString& name)173 bool ComponentManager::unregisterComponent(QString const& name) 174 174 { 175 175 LOG_TRACE("unregisterComponent(name="<< name << ")"); … … 180 180 } 181 181 182 // FIXME: delete component 183 ComponentBase* component = componentMap_.value(name, NULL); 184 //delete component; 185 182 boost::shared_ptr<ComponentBase> component = componentMap_.value(name, NULL); 183 186 184 // FIXME: remove from map (causes segfault in QMap::qMapLessThanKey on Windows) 187 185 //componentMap_.remove(name); 188 186 LOG_INFO("unregistered component '" << name << "'"); 189 190 return true; 191 } 192 193 bool ComponentManager::createComponent(const QString& type, const QString& name) 187 return true; 188 } 189 190 bool ComponentManager::createComponent(QString const& type, QString const& name) 194 191 { 195 192 LOG_TRACE("createComponent(type=" << type << ", " << "name="<< name << ")"); … … 198 195 ComponentFactoryBase* factory = factoryMap_.value(type); 199 196 assert(factory); 200 factory-> addComponent(name);197 factory->createComponent(name); 201 198 return true; 202 199 } … … 209 206 } 210 207 211 bool ComponentManager::loadPlugin( const QString& filename)208 bool ComponentManager::loadPlugin(QString const& filename) 212 209 { 213 210 LOG_TRACE("loadPlugin(filename=" << filename << ")"); … … 236 233 } 237 234 238 bool ComponentManager::checkComponent( const QString& componentName)235 bool ComponentManager::checkComponent(QString const& componentName) 239 236 { 240 237 if (NULL == getComponent(componentName)) { … … 245 242 } 246 243 247 bool ComponentManager::checkComponentInput( const QString & componentName, const QString& inputName)244 bool ComponentManager::checkComponentInput(QString const& componentName, QString const& inputName) 248 245 { 249 246 if (!checkComponent(componentName)) { … … 257 254 } 258 255 259 bool ComponentManager::checkComponentOutput( const QString & componentName, const QString& outputName)256 bool ComponentManager::checkComponentOutput(QString const& componentName, QString const& outputName) 260 257 { 261 258 if (!checkComponent(componentName)) { … … 269 266 } 270 267 271 bool ComponentManager::createConnection( const QString & outputSignature, const QString & inputSignature, const QString& type, int priority = 0)268 bool ComponentManager::createConnection(QString const& outputSignature, QString const& inputSignature, QString const& type, int priority = 0) 272 269 { 273 270 // FIXME: use 2 signatures (output component + output connection) instead of 1 separated by a (".") dot … … 289 286 } 290 287 291 std::size_t ComponentManager::loadComponents( const QString& configFilename)288 std::size_t ComponentManager::loadComponents(QString const& configFilename) 292 289 { 293 290 LOG_TRACE("loadComponents(filename=" << configFilename << ")"); … … 334 331 335 332 // copy locally the config parameters of the component 336 Component Base *component = getComponent(componentName);333 ComponentSharedPointer component = getComponent(componentName); 337 334 if (NULL == component) { 338 335 LOG_WARN("component '" << componentName << "' does not exist"); … … 356 353 QString componentName = cfg.getComponentName(); 357 354 358 Component Base *component = getComponent(componentName);359 if ( NULL ==component) {355 ComponentSharedPointer component = getComponent(componentName); 356 if (!component) { 360 357 LOG_WARN("component '" << componentName << "' does not exist"); 361 358 continue; … … 430 427 } 431 428 432 bool ComponentManager::start( const QString& componentName)429 bool ComponentManager::start(QString const& componentName) 433 430 { 434 431 LOG_TRACE("start(component=" << componentName << ")"); 435 432 436 Component Base*component = getComponent(componentName);433 ComponentSharedPointer component = getComponent(componentName); 437 434 if (!component) { 438 435 LOG_WARN("cannot start component '" << componentName << "'. It does not exist!"); … … 465 462 } 466 463 467 bool ComponentManager::stop(Component Base *component) const464 bool ComponentManager::stop(ComponentSharedPointer component) const 468 465 { 469 466 if (!component) { … … 477 474 } 478 475 479 bool ComponentManager::stop( const QString& componentName)476 bool ComponentManager::stop(QString const& componentName) 480 477 { 481 478 LOG_TRACE("stop(component=" << componentName << ")"); 482 479 483 Component Base*component = getComponent(componentName);480 ComponentSharedPointer component = getComponent(componentName); 484 481 if (!component) { 485 482 LOG_WARN("cannot stop component '" << componentName << "'" << ". It does not exist"); … … 495 492 } 496 493 497 Component Base * ComponentManager::getComponent(const QString& name)494 ComponentSharedPointer ComponentManager::getComponent(QString const& name) 498 495 { 499 496 LOG_TRACE("getComponent(name=" << name << ")"); -
trunk/src/PacpusLib/XmlComponentConfig.cpp
r270 r288 22 22 static const char* kPropertyConnectionPriority = "priority"; 23 23 24 XmlComponentConfig::XmlComponentConfig( const QString& name)24 XmlComponentConfig::XmlComponentConfig(QString const& name) 25 25 { 26 26 LOG_TRACE("XmlComponentConfig(QString)"); … … 43 43 } 44 44 45 void XmlComponentConfig::addProperty( const QString& name)45 void XmlComponentConfig::addProperty(QString const& name) 46 46 { 47 47 if (hasProperty(name)) { … … 62 62 } 63 63 64 int XmlComponentConfig::delProperty( const QString& name)64 int XmlComponentConfig::delProperty(QString const& name) 65 65 { 66 66 if (!hasProperty(name)) { … … 82 82 } 83 83 84 QString XmlComponentConfig::getProperty( const QString& name, const QString& defaultValue) const84 QString XmlComponentConfig::getProperty(QString const& name, QString const& defaultValue) const 85 85 { 86 86 if (!hasProperty(name)) … … 97 97 } 98 98 99 bool XmlComponentConfig::getBoolProperty( const QString& name, bool defaultValue) const99 bool XmlComponentConfig::getBoolProperty(QString const& name, bool defaultValue) const 100 100 { 101 101 return hasProperty(name) ? getProperty(name) == "true" : defaultValue; 102 102 } 103 103 104 int XmlComponentConfig::getIntProperty( const QString& name, int defaultValue) const104 int XmlComponentConfig::getIntProperty(QString const& name, int defaultValue) const 105 105 { 106 106 return hasProperty(name) ? getProperty(name).toInt() : defaultValue; 107 107 } 108 108 109 double XmlComponentConfig::getDoubleProperty( const QString& name, double defaultValue) const109 double XmlComponentConfig::getDoubleProperty(QString const& name, double defaultValue) const 110 110 { 111 111 return hasProperty(name) ? getProperty(name).toDouble() : defaultValue; 112 112 } 113 113 114 void XmlComponentConfig::setProperty( const QString& name, const QString& value)114 void XmlComponentConfig::setProperty(QString const& name, QString const& value) 115 115 { 116 116 component_.setAttribute(name, value); … … 121 121 } 122 122 123 bool XmlComponentConfig::hasProperty( const QString& name) const123 bool XmlComponentConfig::hasProperty(QString const& name) const 124 124 { 125 125 return component_.hasAttribute(name); -
trunk/src/PacpusSensor/src/ui/pacpusmainwindow.h
r162 r288 36 36 public: 37 37 /// @todo Documentation 38 ComponentCheckBox( const QString& text, QWidget * parent, const char * /*name*/ = 0 )38 ComponentCheckBox(QString const& text, QWidget * parent, const char * /*name*/ = 0 ) 39 39 : QCheckBox(text, parent) 40 40 {
Note:
See TracChangeset
for help on using the changeset viewer.