Changeset 484:1a2da4a0243c in finroc_core
- Timestamp:
- 20.03.2021 11:35:42 (23 months ago)
- Branch:
- 17.03
- Children:
- 485:a64142ec340b, 486:774bfa9c0dc8
- Phase:
- public
- Location:
- port
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
port/tPortFactory.cpp
r362 r484 66 66 // Implementation 67 67 //---------------------------------------------------------------------- 68 69 namespace 70 { 71 68 72 /*! 69 73 * \return List of all available port factories … … 75 79 } 76 80 81 class tFactoryAnnotation : public core::tAnnotation 82 { 83 public: 84 85 tFactoryAnnotation(tPortFactory& factory) : 86 factory(factory) 87 {} 88 89 tPortFactory& factory; 90 }; 91 92 } 93 94 77 95 tPortFactory::tPortFactory() 78 96 { … … 80 98 } 81 99 100 tPortFactory::tPortFactory(core::tFrameworkElement* handles_elements_below) 101 { 102 if (handles_elements_below) 103 { 104 handles_elements_below->EmplaceAnnotation<tFactoryAnnotation>(*this); 105 } 106 } 107 82 108 tAbstractPort* tPortFactory::CreatePort(const std::string& port_name, tFrameworkElement& parent, const rrlib::rtti::tType& dt, tFrameworkElement::tFlags flags) 83 109 { 110 { 111 auto check_element_for_attached_factory = &parent; 112 while (check_element_for_attached_factory) 113 { 114 auto annotation = check_element_for_attached_factory->GetAnnotation<tFactoryAnnotation>(); 115 if (annotation && annotation->factory.HandlesDataType(dt)) 116 { 117 return &annotation->factory.CreatePortImplementation(port_name, parent, dt, flags); 118 } 119 check_element_for_attached_factory = check_element_for_attached_factory->GetParent(); 120 } 121 } 122 84 123 std::vector<tPortFactory*>& list = FactoryList(); 85 124 for (auto it = list.begin(); it != list.end(); ++it) -
port/tPortFactory.h
r447 r484 85 85 86 86 /*! 87 * Creates factory that handles only port creation below the specified element 88 * 89 * \param handles_elements_below Framework element that this factory is attached to (inactive/unused if nullptr) 90 */ 91 tPortFactory(core::tFrameworkElement* handles_elements_below); 92 93 94 /*! 87 95 * External interface for anyone who wants to create a port of specified type. 88 96 * For RPC types this will create routing ports only.
Note: See TracChangeset
for help on using the changeset viewer.