- Timestamp:
- Oct 28, 2013, 2:28:14 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/ComponentBase.h
r196 r199 57 57 class OutputInterface; 58 58 59 using ::boost::program_options::value; 60 59 61 /** ComponentBase 60 62 * @brief Base class of a Pacpus component. … … 139 141 virtual void addOutputs() {} 140 142 141 boost::program_options::options_description_easy_init addParameters();142 143 ::boost::program_options::options_description_easy_init addParameters(); 144 143 145 protected: 144 146 typedef QMap<QString, InputInterfaceBase *> InputsMap; -
trunk/include/Pacpus/kernel/InputOutputBase.h
r197 r199 9 9 #include <QApplication> 10 10 #include <QList> 11 #include <QString>12 11 #include <QStringList> 13 12 #include <typeinfo> … … 29 28 QString getSignature() const; 30 29 QString getName() const; 31 virtual QString getDataType() = 0; 30 virtual std::size_t getDataSize() const = 0; 31 virtual const std::type_info & getDataType() const = 0; 32 32 33 33 void addConnection(ConnectionBase connection); … … 72 72 void setReadingMode(ReadingMode mode); 73 73 74 // FIXME: what's the purpose of this function? 74 75 virtual PacpusEvent * getEventTemplate(); 75 76 -
trunk/include/Pacpus/kernel/InputOutputInterface.h
r185 r199 2 2 #define IN_OUT_INTERFACE_H 3 3 4 #include <Pacpus/kernel/InputOutputBase.h> 4 5 #include <Pacpus/kernel/Log.h> 5 #include <Pacpus/kernel/InputOutputBase.h> 6 #include <QApplication> 6 7 7 #include <QByteArray> 8 #include <QThread>8 //#include <QThread> 9 9 #include <typeinfo> 10 10 … … 16 16 { 17 17 public: 18 InputInterface(QString name, C * component, void (C::*m)(const T&)) 18 typedef T data_type; 19 typedef C component_type; 20 typedef void (C::*process_data_function_type)(const T &); 21 22 InputInterface(QString name, C * component, process_data_function_type processMethod) 19 23 : InputInterfaceBase(name, component, component) 20 , method( m)24 , method(processMethod) 21 25 {} 22 26 … … 24 28 {} 25 29 26 s ize_t getDataSize()30 std::size_t getDataSize() const 27 31 { 28 32 return sizeof(T); 29 33 } 30 34 31 QString getDataType()35 const std::type_info & getDataType() const 32 36 { 33 return QString(typeid(T).name());37 return typeid(T); 34 38 } 35 39 36 PacpusEvent* getEventTemplate() 40 // FIXME: what's the purpose of this function? 41 PacpusEvent * getEventTemplate() 37 42 { 38 43 return new PacpusTypedEvent<T>(TYPED_EVENT); 39 44 } 40 45 46 // FIXME: what's the purpose of this function? 41 47 void customEvent(QEvent * event) 42 48 { … … 46 52 case TYPED_EVENT: 47 53 { 48 49 54 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event); 50 55 51 56 LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread()); 52 53 54 57 55 58 if (typedEvent->timerange() < 500 && readingMode() == TimeBounded) { … … 104 107 105 108 protected: 106 void (C::*method)(const T&);109 process_data_function_type method; 107 110 }; 108 111 … … 112 115 { 113 116 public: 117 typedef T data_type; 118 typedef C component_type; 119 114 120 OutputInterface(QString name, C * component) 115 121 : OutputInterfaceBase(name, component, component) 116 122 {} 117 ~OutputInterface() {} 123 124 ~OutputInterface() 125 {} 118 126 119 127 // Used by Components to send data througth typed output 120 128 void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0); 121 129 122 s ize_t getDataSize()130 std::size_t getDataSize() const 123 131 { 124 132 return sizeof(T); 125 133 } 126 134 127 QString getDataType()135 const std::type_info & getDataType() const 128 136 { 129 return QString(typeid(T).name());137 return typeid(T); 130 138 } 131 139 }; -
trunk/src/PacpusLib/ComponentManager.cpp
r185 r199 6 6 /// @version $Id: ComponentManager.cpp 76 2013-01-10 17:05:10Z kurdejma $ 7 7 8 #include <Pacpus/kernel/ComponentManager.h> 9 8 10 #include <Pacpus/kernel/ComponentFactoryBase.h> 9 #include <Pacpus/kernel/ComponentManager.h>10 11 #include <Pacpus/kernel/ComponentBase.h> 11 12 #include <Pacpus/kernel/ConnectionBase.h> 12 13 #include <Pacpus/kernel/InputOutputBase.h> 13 14 #include <Pacpus/kernel/Log.h> 15 14 16 #include <QDomNodeList> 15 17 #include <QObject> … … 27 29 bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode) 28 30 { 29 if (out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) { 31 if ((out->getDataType() == in->getDataType()) 32 || (out->getDataType() == typeid(QByteArray)) 33 || (in->getDataType() == typeid(QByteArray))) { 30 34 // Add connection 31 35 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function
Note:
See TracChangeset
for help on using the changeset viewer.