| 83 | |
| 84 | template <typename F> |
| 85 | class FactoryList { |
| 86 | public: |
| 87 | FactoryList() {} |
| 88 | ~FactoryList() { |
| 89 | typename FList::iterator it; |
| 90 | for (it = list_.begin(); list_.end() != it; ++it) { |
| 91 | delete it->second, it->second = nullptr; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | void AddFactory(int handle_id, F *factory) { |
| 96 | list_.push_back(std::make_pair(handle_id, factory)); |
| 97 | } |
| 98 | |
| 99 | F *GetFactory(int handle_id) { |
| 100 | typename FList::iterator it; |
| 101 | for (it = list_.begin(); list_.end() != it; ++it) { |
| 102 | if (it->first == handle_id) return it->second; |
| 103 | } |
| 104 | return nullptr; |
| 105 | } |
| 106 | |
| 107 | private: |
| 108 | typedef std::vector<std::pair<int, F *>> FList; |
| 109 | |
| 110 | FList list_; |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | } // namespace comm |
nothing calls this directly
no outgoing calls
no test coverage detected