aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/oo/Register_Implement.hpp
blob: 206b0a3796783b2d8f2543a3004951d946df0de6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <map>
#include <vector>

namespace meow{
  template<class T>
  inline RegisterInterface<T>::RegisterInterface(){ }
  template<class T>
  inline bool RegisterInterface<T>::regImplement(ImplementInterface<T>* imp){
    if(implements.find(imp->identify()) != implements.end()){
      return false;
    }
    implements[imp->identify()] = imp;
    return true;
  }
  template<class T>
  inline ImplementInterface<T>*
  RegisterInterface<T>::getImplement(T const& identify){
    if(implements.find(identify) == implements.end()){
      return NULL;
    }
    return implements[identify];
  }
  template<class T>
  inline std::vector<T>
  RegisterInterface<T>::getIdentifys() const{
    std::vector<T> ret;
    for(typename std::map<T, ImplementInterface<T>*>::const_iterator
        it = implements.begin(); it != implements.end(); it++){
      ret.push_back(it->first);
    }
    return ret;
  }
}