MCPcopy Create free account
hub / github.com/Tencent/phxqueue / FactoryList

Class FactoryList

phxqueue/comm/handler.h:85–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84template <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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected