Changeset 185 in pacpusframework for trunk/include/Pacpus
- Timestamp:
- Oct 23, 2013, 10:32:21 AM (11 years ago)
- Location:
- trunk/include/Pacpus/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/InputOutputBase.h
r182 r185 66 66 virtual ~InputInterfaceBase(); 67 67 68 virtual void customEvent(QEvent * e);68 virtual void customEvent(QEvent * e); 69 69 70 70 ReadingMode & readingMode(); 71 const ReadingMode & readingMode() const;71 const ReadingMode & getReadingMode() const; 72 72 void setReadingMode(ReadingMode mode); 73 73 … … 96 96 QStringList getInputConnectedList(); 97 97 98 // TODO for serialization prupose (not yet implemented !!!)99 98 void send(/*const*/ QByteArray & data); 100 99 }; 101 102 namespace {103 104 bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode = InputInterfaceBase::GetLast);105 106 bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode)107 {108 if (out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) {109 // Add connection110 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function111 in->addConnection(ConnectionBase(out, priority));112 in->setReadingMode(mode);113 //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature());114 return true;115 } else {116 //LOG_WARN("connecting " << out->getSignature() << ":" << out->getDataType() << " to " << in->getSignature() << ":" << in->getDataType() << " failled : DataType incompatible " << QString(typeid(QByteArray).name()));117 return false;118 }119 }120 121 } // namespace122 100 123 101 } // namespace pacpus -
trunk/include/Pacpus/kernel/InputOutputInterface.h
r184 r185 96 96 97 97 // TODO for Pulling mode (not yet implemented !!!) 98 T & getData() {98 T & getData() { 99 99 T data; 100 100 // TODO ask output data; … … 105 105 protected: 106 106 void (C::*method)(const T&); 107 108 107 }; 109 108 110 109 template <typename T, class C> 111 class OutputInterface : public OutputInterfaceBase 110 class OutputInterface 111 : public OutputInterfaceBase 112 112 { 113 113 public: 114 114 OutputInterface(QString name, C * component) 115 : OutputInterfaceBase(name,component,component)115 : OutputInterfaceBase(name, component, component) 116 116 {} 117 117 ~OutputInterface() {} … … 120 120 void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0); 121 121 122 void send(const T & data, road_time_t t, road_timerange_t tr)123 {124 // FIXME Data Shared125 //QSharedPointer<T> sharedPointer = new T(data);126 127 for (QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) {128 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler129 //qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " ";130 }131 }132 133 122 size_t getDataSize() 134 123 { … … 142 131 }; 143 132 133 template <typename T, class C> 134 void OutputInterface<T, C>::send(const T & data, road_time_t t, road_timerange_t tr) 135 { 136 // FIXME Data Shared 137 //QSharedPointer<T> sharedPointer = new T(data); 138 139 for (QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) { 140 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler 141 //qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " "; 142 } 143 } 144 144 145 } // namespace pacpus 145 146
Note:
See TracChangeset
for help on using the changeset viewer.