- Timestamp:
- Oct 23, 2013, 9:09:51 AM (11 years ago)
- Location:
- trunk/src/PacpusLib
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/PacpusLib/CMakeLists.txt
r156 r182 71 71 72 72 set(PROJECT_SRCS 73 ./ComponentBase.cpp 74 ./ComponentFactoryBase.cpp 75 ./ComponentManager.cpp 76 ./Log.cpp 77 ./PacpusApplication.cpp 78 ./PacpusException.cpp 79 ./XmlComponentConfig.cpp 80 ./XmlConfigFile.cpp 81 ./InputOutputBase.cpp 82 # ./PacpusStruct.cpp 73 ComponentBase.cpp 74 ComponentFactoryBase.cpp 75 ComponentManager.cpp 76 ConnectionBase.cpp 77 InputOutputBase.cpp 78 Log.cpp 79 PacpusApplication.cpp 80 PacpusException.cpp 81 # PacpusStruct.cpp 82 XmlComponentConfig.cpp 83 XmlConfigFile.cpp 83 84 ) 84 85 -
trunk/src/PacpusLib/ComponentBase.cpp
r181 r182 6 6 7 7 #include <Pacpus/kernel/ComponentBase.h> 8 8 9 #include <Pacpus/kernel/ComponentManager.h> 9 10 #include <Pacpus/kernel/Log.h> … … 20 21 using namespace std; 21 22 22 std::vector<std::string> convertAttributesToArgumentVector(const QDomNamedNodeMap & attributes);23 void logVariablesMap( boost::program_options::variables_map vm);23 vector<string> convertAttributesToArgumentVector(const QDomNamedNodeMap & attributes); 24 void logVariablesMap(po::variables_map vm); 24 25 25 26 DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase"); 26 27 27 ComponentBase::ComponentBase(const QString & componentName)28 : m_componentName(componentName)29 , m_isActive(false)30 , mIsRecording(true)31 , m_manager(NULL)32 , m_ui(NULL)33 , m_componentState(NOT_MONITORED)34 , mOptionsDescription("Component parameters")28 ComponentBase::ComponentBase(const QString & componentName) 29 : m_componentName(componentName) 30 , m_isActive(false) 31 , mIsRecording(true) 32 , m_manager(NULL) 33 , m_ui(NULL) 34 , m_componentState(NOT_MONITORED) 35 , mOptionsDescription("Component parameters") 35 36 { 36 37 LOG_TRACE("constructor"); … … 172 173 { 173 174 /* QList<QString> keys = output.keys(); 174 for (int i=0; i<keys.size();++i)175 for (int i=0; i<keys.size();++i) 175 176 LOG_INFO("Key : " << keys[i])*/; 176 177 -
trunk/src/PacpusLib/ComponentManager.cpp
r176 r182 10 10 #include <Pacpus/kernel/ComponentBase.h> 11 11 #include <Pacpus/kernel/ConnectionBase.h> 12 #include <Pacpus/kernel/InputOutputBase.h> 12 13 #include <Pacpus/kernel/Log.h> 14 #include <QDomNodeList> 13 15 #include <QObject> 14 #include <QDomNodeList> 15 16 17 using namespace pacpus; 16 18 using namespace pacpus; 17 19 … … 186 188 QStringList input = inputSignature.split("."); 187 189 188 if (getComponent(output[0])==NULL) {190 if (getComponent(output[0])==NULL) { 189 191 LOG_WARN("cannot make connection : component " << output[0] << " not found"); 190 192 return false;} 191 if (getComponent(output[0])->getOutput(output[1]) == NULL) {193 if (getComponent(output[0])->getOutput(output[1]) == NULL) { 192 194 LOG_WARN("cannot make connection : component " << output[0] << " doesn't have output " << output[1]); 193 195 return false;} 194 if (getComponent(input[0])==NULL) {196 if (getComponent(input[0])==NULL) { 195 197 LOG_WARN("cannot make connection : component " << input[0] << " not found"); 196 198 return false;} 197 if (getComponent(input[0])->getInput(input[1]) == NULL) {199 if (getComponent(input[0])->getInput(input[1]) == NULL) { 198 200 LOG_WARN("cannot make connection : component " << input[0] << " doesn't have intput " << input[1]); 199 201 return false;} 200 202 201 203 // NOTE Create communicationInterface if needed ?? 202 203 return connectInterface(getComponent(output[0])->getOutput(output[1]), getComponent(input[0])->getInput(input[1]), priority); 204 return connectInterface( 205 getComponent(output[0])->getOutput(output[1]), 206 getComponent(input[0])->getInput(input[1]), 207 priority 208 ); 204 209 205 210 } -
trunk/src/PacpusLib/InputOutputBase.cpp
r148 r182 1 #include <Pacpus/kernel/InputOutputBase.h> 2 1 3 #include <Pacpus/kernel/ComponentBase.h> 4 #include <Pacpus/kernel/ConnectionBase.h> 5 #define CONNECT_INTERFACE_EXPORTS 2 6 #include <Pacpus/kernel/InputOutputInterface.h> 7 #undef CONNECT_INTERFACE_EXPORTS 3 8 #include <Pacpus/kernel/Log.h> 4 9 … … 7 12 DECLARE_STATIC_LOGGER("pacpus.core.InputOutputInterface"); 8 13 9 QString AbstractInterface::getSignature() 14 //////////////////////////////////////////////////////////////////////////////// 15 16 AbstractInterface::AbstractInterface(QString name, ComponentBase * component, QObject * parent) 17 : m_name(name) 18 , m_component(component) 19 , QObject(parent) 10 20 { 11 return component()->getName() + '.' + name();21 LOG_DEBUG("constructing abstract connection '" << getName() << "'"); 12 22 } 23 24 AbstractInterface::~AbstractInterface() 25 {} 26 27 QString AbstractInterface::getSignature() const 28 { 29 return getComponent()->getName() + '.' + getName(); 30 } 31 32 QString AbstractInterface::getName() const 33 { 34 return m_name; 35 } 36 37 QList<ConnectionBase> & AbstractInterface::connections() 38 { 39 return m_connections; 40 } 41 42 const QList<ConnectionBase> & AbstractInterface::getConnections() const 43 { 44 return m_connections; 45 } 46 47 ComponentBase * AbstractInterface::component() 48 { 49 return m_component; 50 } 51 52 const ComponentBase * AbstractInterface::getComponent() const 53 { 54 return m_component; 55 } 56 57 void AbstractInterface::addConnection(ConnectionBase connection) 58 { 59 m_connections.append(connection); 60 } 61 62 bool AbstractInterface::removeConnection(ConnectionBase connection) 63 { 64 return m_connections.removeOne(connection); 65 } 66 67 bool AbstractInterface::hasConnection() 68 { 69 return m_connections.size() > 0; 70 } 71 72 //////////////////////////////////////////////////////////////////////////////// 73 74 InputInterfaceBase::InputInterfaceBase(QString name, ComponentBase * component, QObject * parent) 75 : AbstractInterface(name, component, parent) 76 {} 77 78 InputInterfaceBase::~InputInterfaceBase() 79 {} 80 81 // TODO for serialization prupose (not yet implemented !!!) 82 void InputInterfaceBase::customEvent(QEvent* e) 83 { 84 //if (event->type()) 85 //TODO get event Type anf call callback function 86 87 PacpusEvent * event = dynamic_cast<PacpusEvent *>(e); 88 QByteArray buf; 89 QDataStream out(&buf, QIODevice::WriteOnly); 90 event->streamOut(out); 91 // Callback QByteArray 92 } 93 94 InputInterfaceBase::ReadingMode & InputInterfaceBase::readingMode() 95 { 96 return m_readingMode; 97 } 98 99 const InputInterfaceBase::ReadingMode & InputInterfaceBase::readingMode() const 100 { 101 return m_readingMode; 102 } 103 104 void InputInterfaceBase::setReadingMode(ReadingMode mode) 105 { 106 m_readingMode = mode; 107 } 108 109 PacpusEvent * InputInterfaceBase::getEventTemplate() 110 { 111 // TODO: check 112 return new PacpusEvent(GENERIC_EVENT); 113 } 114 115 //////////////////////////////////////////////////////////////////////////////// 116 117 QStringList OutputInterfaceBase::getInputConnectedList() 118 { 119 QStringList list; 120 for (QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) { 121 list.append(it->getInterface()->getName()); 122 } 123 return list; 124 } 125 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 }
Note:
See TracChangeset
for help on using the changeset viewer.