- Timestamp:
- Oct 29, 2013, 3:40:48 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/ProducerConsumerExample/ProducerExample.cpp
r177 r202 94 94 ); 95 95 96 if (imageOutput && imageOutput->hasConnection()) { 97 imageOutput->send(mat); 98 } 96 checkedSend(imageOutput, mat); 99 97 100 98 LOG_INFO("Sent data=" << counter << ", time=" << road_time()); -
trunk/include/Pacpus/kernel/ComponentBase.h
r201 r202 101 101 QString getName() const; 102 102 103 /// @todo DOC104 InputInterfaceBase * getInput(QString name) const;105 106 /// @todo DOC107 OutputInterfaceBase * getOutput(QString name) const;108 109 103 protected: 110 104 /// Changes the state of the component. … … 155 149 outputs().insert(name, connection); 156 150 } 151 152 /// @todo DOC 153 InputInterfaceBase * getInput(QString name) const; 154 155 /// @todo DOC 156 OutputInterfaceBase * getOutput(QString name) const; 157 157 158 158 template <typename DataType, class ComponentType> -
trunk/include/Pacpus/kernel/InputOutputInterface.h
r200 r202 5 5 #include <Pacpus/kernel/Log.h> 6 6 7 #include <QApplication>8 7 #include <QByteArray> 9 8 #include <QCoreApplication> … … 147 146 148 147 for (QList<ConnectionBase>::iterator it = connections().begin(), itend = connections().end(); it != itend; ++it) { 149 // Event is deleted by the event loop handler 150 QApplication::postEvent(it->getInterface(), new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); 151 //qDebug() << "sender " << it->getInterface()->getSignature() << " Data & " << &data << " "; 148 // Qt documentatino: 149 // The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. 150 // It is not safe to access the event after it has been posted. 151 QEvent * newEvent = new PacpusTypedEvent<T>(TYPED_EVENT, data, t, tr); 152 QCoreApplication::postEvent(it->getInterface(), newEvent, it->getPriority()); 153 LOG_DEBUG("Sender: " << it->getInterface()->getSignature()); 154 LOG_DEBUG("Data &: " << &data); 152 155 } 156 } 157 158 template <typename T1, typename T2, class C> 159 bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t = road_time(), road_timerange_t tr = 0); 160 161 template <typename T1, typename T2, class C> 162 bool checkedSend(OutputInterface<T1, C> * sender, const T2 & data, road_time_t t, road_timerange_t tr) 163 { 164 if (sender && sender->hasConnection()) { 165 sender->send(data, t, tr); 166 return true; 167 } 168 return false; 153 169 } 154 170 -
trunk/src/PacpusLib/ComponentBase.cpp
r201 r202 13 13 #include <boost/program_options/parsers.hpp> 14 14 #include <boost/program_options/variables_map.hpp> 15 #include <ostream> 15 16 #include <string> 16 17 #include <vector> 17 18 const bool kPropertyVerboseDefaultValue = false;19 18 20 19 namespace po = boost::program_options; … … 23 22 24 23 vector<string> convertAttributesToArgumentVector(const QDomNamedNodeMap & attributes); 25 void logVariablesMap(po::variables_map vm); 24 25 namespace std { 26 27 template <typename _Elem, typename _Traits> 28 std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const boost::program_options::variables_map & vm) 29 { 30 for (po::variables_map::const_iterator i = vm.cbegin(); i != vm.cend(); ++i) { 31 const po::variable_value & v = i->second; 32 if (v.empty()) { 33 continue; 34 } 35 const type_info & type = v.value().type(); 36 if (type == typeid(string)) { 37 const string & val = v.as<string>(); 38 os << i->first << "=" << val; 39 } else if (type == typeid(long)) { 40 int val = v.as<long>(); 41 os << i->first << "=" << val; 42 } else if (type == typeid(int)) { 43 int val = v.as<int>(); 44 os << i->first << "=" << val; 45 } else if (type == typeid(unsigned long)) { 46 int val = v.as<unsigned long>(); 47 os << i->first << "=" << val; 48 } else if (type == typeid(unsigned int)) { 49 int val = v.as<unsigned int>(); 50 os << i->first << "=" << val; 51 } else if (type == typeid(double)) { 52 int val = v.as<double>(); 53 os << i->first << "=" << val; 54 } else if (type == typeid(float)) { 55 int val = v.as<float>(); 56 os << i->first << "=" << val; 57 } else if (type == typeid(bool)) { 58 int val = v.as<bool>(); 59 os << i->first << "=" << val; 60 } 61 } 62 return os; 63 } 64 65 } // namespace std 26 66 27 67 DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase"); … … 225 265 } 226 266 227 logVariablesMap(vm); 228 } 229 230 void logVariablesMap(boost::program_options::variables_map vm) 231 { 232 for (po::variables_map::iterator i = vm.begin(); i != vm.end(); ++i) { 233 const po::variable_value& v = i->second; 234 if (v.empty()) { 235 continue; 236 } 237 const type_info & type = v.value().type(); 238 if (type == typeid(string)) { 239 const string & val = v.as<string>(); 240 LOG_INFO(i->first << "=" << val); 241 } else if (type == typeid(int)) { 242 int val = v.as<int>(); 243 LOG_INFO(i->first << "=" << val); 244 } else if (type == typeid(bool)) { 245 int val = v.as<bool>(); 246 LOG_INFO(i->first << "=" << val); 247 } 248 } 267 LOG_INFO(vm); 249 268 } 250 269 -
trunk/src/PacpusLib/ComponentManager.cpp
r201 r202 17 17 #include <QDomNodeList> 18 18 #include <QObject> 19 #include <QList> 20 #include <ostream> 19 21 20 22 using namespace pacpus; 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 } 21 33 22 34 DECLARE_STATIC_LOGGER("pacpus.core.ComponentManager"); … … 316 328 } 317 329 318 // Pacpus 2.0 :add inputs and outputs330 // add inputs and outputs 319 331 component->addInputs(); 320 332 component->addOutputs(); 333 // print inputs and outputs 334 LOG_INFO("Inputs: " << component->inputs().keys()); 335 LOG_INFO("Outputs: " << component->outputs().keys()); 321 336 322 337 if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) {
Note:
See TracChangeset
for help on using the changeset viewer.