Changeset 206 in pacpusframework for trunk/src/PacpusLib
- Timestamp:
- Oct 30, 2013, 12:26:34 PM (11 years ago)
- Location:
- trunk/src/PacpusLib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/PacpusLib/ComponentBase.cpp
r204 r206 214 214 OutputInterfaceBase * ComponentBase::getOutput(QString outputName) const 215 215 { 216 /* QList<QString> keys = output.keys();217 for (int i=0; i<keys.size();++i)218 LOG_INFO("Key : " << keys[i])*/;219 220 216 if (outputs().contains(outputName)) { 221 217 return outputs()[outputName]; 222 218 } 223 LOG_WARN("Component " << getName() << " does not contain toutput " << outputName);219 LOG_WARN("Component " << getName() << " does not contain output " << outputName); 224 220 return NULL; 225 221 } -
trunk/src/PacpusLib/ComponentManager.cpp
r204 r206 22 22 using namespace pacpus; 23 23 24 //template <typename _Elem, typename _Traits, typename _ListElem> 25 //std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const QList<_ListElem> & list) 26 //{ 27 // typedef QList<_ListElem> ListType; 28 // for (ListType::const_iterator it = list.cbegin(), itend = list.cend(); it != itend; ++it) { 29 // os << *it << "\n"; 30 // } 31 // return os; 32 //} 33 24 34 template <typename _Elem, typename _Traits, typename _ListElem> 25 35 std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const QList<_ListElem> & list) … … 36 46 //////////////////////////////////////////////////////////////////////////////// 37 47 48 /// Connects OutputInterfaceBase @b out to InputInterfaceBase @b in using given priority and reading mode. 49 /// @returns @b true if connection has been added successfully, @b false otherwise. 38 50 bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode = InputInterfaceBase::GetLast); 39 51 … … 42 54 bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode) 43 55 { 44 if ((out->getDataType() == in->getDataType()) 45 || (out->getDataType() == typeid(QByteArray)) 46 || (in->getDataType() == typeid(QByteArray))) { 47 // Add connection 48 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function 49 in->addConnection(ConnectionBase(out, priority)); 50 in->setReadingMode(mode); 51 //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature()); 52 return true; 53 } else { 54 //LOG_WARN("connecting " << out->getSignature() << ":" << out->getDataType() << " to " << in->getSignature() << ":" << in->getDataType() << " failled : DataType incompatible " << QString(typeid(QByteArray).name())); 55 return false; 56 } 56 // check connections 57 if (!out || !in) { 58 LOG_WARN("null connection"); 59 return false; 60 } 61 62 // check if connection type are compatible 63 // FIXME: it should permit an OutputType to be a type conversible to InputType 64 if (out->getDataType() != in->getDataType()) { 65 LOG_WARN("connection types do not match: " 66 << out->getSignature() << "." << out->getDataType().name() 67 << " -> " 68 << in->getSignature() << "." << in->getDataType().name() 69 ); 70 return false; 71 } 72 //if ((out->getDataType() == in->getDataType()) 73 // || (out->getDataType() == typeid(QByteArray)) 74 // || (in->getDataType() == typeid(QByteArray))) { 75 76 // add connection 77 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function 78 in->addConnection(ConnectionBase(out, priority)); 79 in->setReadingMode(mode); 80 //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature()); 81 return true; 57 82 } 58 83 … … 145 170 LOG_TRACE("registerComponent(name="<< name << ")"); 146 171 147 if (componentMap_.contains(name)) 148 { 172 if (componentMap_.contains(name)) { 149 173 LOG_WARN("cannot register component '" << name << "'. A component with the same name exists already"); 150 174 return false; … … 235 259 } 236 260 237 bool ComponentManager::createConnection(const QString & outputSignature, const QString& inputSignature, const QString& type, int priority = 0)261 bool ComponentManager::createConnection(const QString & outputSignature, const QString & inputSignature, const QString & type, int priority = 0) 238 262 { 239 263 // FIXME: use 2 signatures (output component + output connection) instead of 1 separated by a (".") dot … … 247 271 return false; 248 272 } 249 // NOTECreate communicationInterface if needed ??273 // FIXME: Create communicationInterface if needed ?? 250 274 return connectInterface( 251 275 getComponent(output[0])->getOutput(output[1]), -
trunk/src/PacpusLib/ConnectionManager.cpp
r89 r206 1 2 1 #include <Pacpus/kernel/ConnectionManager.h> 3 2 #include <Pacpus/kernel/Log.h> … … 15 14 { 16 15 LOG_TRACE("destructor"); 17 18 19 16 } 20 17 … … 41 38 LOG_TRACE(Q_FUNC_INFO); 42 39 43 ComponentManager *mgr = ComponentManager::getInstance(); 44 40 ComponentManager * mgr = ComponentManager::getInstance(); 45 41 46 42 // TODO read XML file and build ConnectionList 47 43 QList<ConnectionDescriptor> ConnectionList; 48 ConnectionList.append(ConnectionDescriptor("testComponent1", "image","testComponent2","image","type"));44 ConnectionList.append(ConnectionDescriptor("testComponent1", "image", "testComponent2", "image", "type")); 49 45 50 46 ComponentBase * sender, * receiver; … … 52 48 OutputInterfaceBase * out; 53 49 54 for(QList<ConnectionDescriptor>::iterator i = ConnectionList.begin(); i != ConnectionList.end(); ++i) { 55 50 for (QList<ConnectionDescriptor>::iterator i = ConnectionList.begin(); i != ConnectionList.end(); ++i) { 56 51 // TODO Handle errors 57 52 sender = mgr->getComponent(i->_outputComponent); 58 53 out = sender->getOutput(i->_outputName); 59 60 54 61 55 receiver = mgr->getComponent(i->_inputComponent); … … 66 60 LOG_INFO(" Output " << "out" << " connected to " << "in") // TODO replace out / in 67 61 } 68 69 62 70 63 // CledComponent * cledComponent = (CledComponent*) m_component[cName]; … … 82 75 // in1->setConnection(buffer,true); 83 76 // out1->setConnection(buffer,true); 84 85 86 77 } 87 -
trunk/src/PacpusLib/InputOutputBase.cpp
r200 r206 5 5 #include <Pacpus/kernel/InputOutputInterface.h> 6 6 #include <Pacpus/kernel/Log.h> 7 8 #include <QApplication>9 7 10 8 using namespace pacpus; … … 124 122 } 125 123 126 // TODO for serialization prupose (not yet implemented !!!) 127 void OutputInterfaceBase::send(/*const*/ QByteArray & data) 128 { 129 // TODO check at least one Typed connection 130 131 for (QList<ConnectionBase>::iterator it = connections().begin(); it!=connections().end(); ++it) { 132 QDataStream in(&data,QIODevice::ReadOnly); 133 PacpusEvent * event = dynamic_cast<InputInterfaceBase*>(connections().at(0).getInterface())->getEventTemplate(); 134 event->streamIn(in); 135 QApplication::postEvent(it->getInterface(),event,it->getPriority()); 136 } 137 } 124 // TODO for serialization purpose (not yet implemented !!!) 125 //void OutputInterfaceBase::send(/*const*/ QByteArray & data) 126 //{ 127 // // TODO check at least one Typed connection 128 // 129 // for (QList<ConnectionBase>::iterator it = connections().begin(), itend = connections().end(); it != itend; ++it) { 130 // QDataStream in(&data, QIODevice::ReadOnly); 131 // InputInterfaceBase * interfaceBase 132 // = dynamic_cast<InputInterfaceBase *>(connections().at(0).getInterface()); 133 // //AbstractInterface * interfaceBase = connections().at(0).getInterface(); 134 // if (!interfaceBase) { 135 // continue; 136 // } 137 // PacpusEvent * event = interfaceBase->getEventTemplate(); 138 // if (!event) { 139 // continue; 140 // } 141 // event->streamIn(in); 142 // QCoreApplication::postEvent( 143 // it->getInterface(), 144 // event, 145 // it->getPriority() 146 // ); 147 // } 148 //}
Note:
See TracChangeset
for help on using the changeset viewer.