Changeset 182 in pacpusframework for trunk/include/Pacpus/kernel
- Timestamp:
- Oct 23, 2013, 9:09:51 AM (11 years ago)
- Location:
- trunk/include/Pacpus/kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/Pacpus/kernel/ComponentBase.h
r181 r182 24 24 25 25 #include <Pacpus/kernel/ComponentManager.h> 26 #include <Pacpus/kernel/InputOutputBase.h> 26 27 #include <Pacpus/kernel/pacpus.h> 27 28 #include <Pacpus/kernel/XmlComponentConfig.h> 28 #include <Pacpus/kernel/InputOutputBase.h>29 29 30 30 #include <QString> -
trunk/include/Pacpus/kernel/ConnectionBase.h
r153 r182 11 11 { 12 12 public: 13 ConnectionBase(AbstractInterface * interface, int priority) 14 : m_interface(interface) 15 , m_priority(priority) 16 {} 13 ConnectionBase(AbstractInterface * anInterface, int priority); 14 virtual ~ConnectionBase(); 17 15 18 ~ConnectionBase() 19 {} 20 21 AbstractInterface * getInterface() const 22 { 23 return m_interface; 24 } 25 26 int getPriority() const 27 { 28 return m_priority; 29 } 30 31 bool operator==(ConnectionBase const &c) 32 { 33 return getInterface() == c.getInterface() 34 && getPriority() == c.getPriority() 35 ; 36 } 16 AbstractInterface * getInterface() const; 17 int getPriority() const; 18 bool operator==(ConnectionBase const & c); 37 19 38 20 private: -
trunk/include/Pacpus/kernel/InputOutputBase.h
r159 r182 2 2 #define IN_OUT_BASE_H 3 3 4 #include <Pacpus/kernel/ConnectionBase.h> 4 5 #include <Pacpus/kernel/Log.h> 5 6 #include <Pacpus/kernel/pacpus.h> 6 #include <Pacpus/kernel/ConnectionBase.h>7 7 #include <Pacpus/kernel/PacpusEvent.h> 8 8 … … 23 23 24 24 protected: 25 AbstractInterface(QString name, ComponentBase * component, QObject * parent = 0) 26 : m_name(name) 27 , m_component(component) 28 , QObject(parent) 29 { 30 LOG_DEBUG("constructing abstract connection '" << getName() << "'"); 31 } 32 33 ~AbstractInterface() 34 {} 25 AbstractInterface(QString name, ComponentBase * component, QObject * parent = 0); 26 virtual ~AbstractInterface(); 35 27 36 28 public: 37 QString getSignature(); 38 QString getName() 39 { 40 return m_name; 41 } 42 29 QString getSignature() const; 30 QString getName() const; 43 31 virtual QString getDataType() = 0; 44 32 45 ComponentBase * getComponent() 46 { 47 return m_component; 48 } 49 50 void addConnection(ConnectionBase connection) 51 { 52 m_connections.append(connection); 53 } 54 55 bool removeConnection(ConnectionBase connection) 56 { 57 return m_connections.removeOne(connection); 58 } 59 60 bool hasConnection() 61 { 62 return m_connections.size() > 0; 63 } 33 void addConnection(ConnectionBase connection); 34 bool removeConnection(ConnectionBase connection); 35 bool hasConnection(); 64 36 65 37 protected: 66 QList<ConnectionBase> & connections() 67 { 68 return m_connections; 69 } 38 QList<ConnectionBase> & connections(); 39 const QList<ConnectionBase> & getConnections() const; 70 40 71 const QList<ConnectionBase> & connections() const 72 { 73 return m_connections; 74 } 75 76 QString name() 77 { 78 return m_name; 79 } 80 81 ComponentBase * component() 82 { 83 return m_component; 84 } 85 86 const ComponentBase * component() const 87 { 88 return m_component; 89 } 41 ComponentBase * component(); 42 const ComponentBase * getComponent() const; 90 43 91 44 private: … … 101 54 102 55 protected: 103 InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0) 104 : AbstractInterface(name, component, parent) 105 {} 56 // TODO: add ctor with function pointer 57 InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0); 106 58 107 59 public: 108 //InputInterfaceBase(QString name, ComponentBase * component,int a, QObject * parent = 0):AbstractInterface(name,component,parent) {} // TODO add ctor with function pointer109 110 60 enum ReadingMode { 111 61 NeverSkip, … … 114 64 }; 115 65 116 virtual ~InputInterfaceBase() 117 {} 66 virtual ~InputInterfaceBase(); 118 67 119 // TODO for serealization prupose (not yet implemented !!!) 120 virtual void customEvent(QEvent* e) 121 { 122 //if(event->type()) 123 //TODO get event Type anf call callback function 68 virtual void customEvent(QEvent* e); 124 69 125 PacpusEvent * event = dynamic_cast<PacpusEvent *>(e); 126 QByteArray buf; 127 QDataStream out(&buf, QIODevice::WriteOnly); 128 event->streamOut(out); 129 // Callback QByteArray 130 } 70 ReadingMode & readingMode(); 71 const ReadingMode & readingMode() const; 72 void setReadingMode(ReadingMode mode); 131 73 132 ReadingMode & readingMode() 133 { 134 return m_readingMode; 135 } 136 137 const ReadingMode & readingMode() const 138 { 139 return m_readingMode; 140 } 141 142 void setReadingMode(ReadingMode mode) 143 { 144 m_readingMode = mode; 145 } 146 147 virtual PacpusEvent* getEventTemplate() 148 { 149 // TODO: check 150 return new PacpusEvent(GENERIC_EVENT); 151 } 74 virtual PacpusEvent * getEventTemplate(); 152 75 153 76 private: … … 171 94 {} 172 95 173 QStringList getInputConnectedList() 174 { 175 QStringList list; 176 for(QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) { 177 list.append(it->getInterface()->getName()); 178 } 179 return list; 180 } 96 QStringList getInputConnectedList(); 181 97 182 // TODO for serealization prupose (not yet implemented !!!) 183 void send(/*const*/ QByteArray & data) 184 { 185 // TODO check at least one Typed connection 186 187 for(QList<ConnectionBase>::iterator it = connections().begin(); it!=connections().end(); ++it){ 188 QDataStream in(&data,QIODevice::ReadOnly); 189 PacpusEvent* event = dynamic_cast<InputInterfaceBase*>(connections().at(0).getInterface())->getEventTemplate(); 190 event->streamIn(in); 191 QApplication::postEvent(it->getInterface(),event,it->getPriority()); 192 } 193 } 194 98 // TODO for serialization prupose (not yet implemented !!!) 99 void send(/*const*/ QByteArray & data); 195 100 }; 196 101 197 static bool connectInterface(OutputInterfaceBase* out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode = InputInterfaceBase::GetLast) 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) 198 107 { 199 if (out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) {108 if (out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) { 200 109 // Add connection 201 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function202 in->addConnection(ConnectionBase(out, priority));110 out->addConnection(ConnectionBase(in, priority)); // TODO make connect function 111 in->addConnection(ConnectionBase(out, priority)); 203 112 in->setReadingMode(mode); 204 113 //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature()); … … 210 119 } 211 120 121 } // namespace 122 212 123 } // namespace pacpus 213 124 -
trunk/include/Pacpus/kernel/InputOutputInterface.h
r159 r182 42 42 { 43 43 // TODO check component state started 44 //if (_component) get state44 //if (_component) get state 45 45 switch (event->type()) { 46 46 case TYPED_EVENT:
Note:
See TracChangeset
for help on using the changeset viewer.