aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/oo/Register_Implement.hpp
blob: bee7f3e536e8313893654a47a8aa860527e478b0 (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
34
35
36
#include "Register_Implement.h"


#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;
  }
}