Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MMLMonitorDisplayFactory.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef MMLMonitorDisplayFactory_H
27 #define MMLMonitorDisplayFactory_H
28 
29 #include <map>
30 #include <vector>
31 
32 #include "monitor/Monitor.h"
33 
34 #include "MMLComponent.h"
35 #include "MMLMonitorDisplay.h"
36 
42 
43  public:
44 
47 
56  template<typename C>
57  bool registerClass(std::string id,Monitor::type type){
58  if (mapObjectCreator.find(id) != mapObjectCreator.end()){
59  return false;
60  }else{
61  mapObjectCreator.insert( std::make_pair<std::string,CreateMonitorDisplayFunctionPointer>(id, &createTheMonitorDisplay<C> ) );
62  displaysByType[type].push_back(id);
63  return true;
64  }
65  }
66 
73  template<typename C>
74  bool registerClass(std::string id){
75  if (mapObjectCreator.find(id) != mapObjectCreator.end()){
76  return false;
77  }else{
78  mapObjectCreator.insert( std::make_pair<std::string,CreateMonitorDisplayFunctionPointer>(id, &createTheMonitorDisplay<C> ) );
79  for (unsigned int i=0;i<Monitor::typeCount;i++){
80  displaysByType[i].push_back(id);
81  }
82  return true;
83  }
84  }
85 
87  bool isRegistered(std::string id);
88 
90  MMLMonitorDisplay* createMonitorDisplay(std::string id,Monitor* monitor,MMLComponent* manager);
91 
93  unsigned int getNumberOfDisplaysByType(Monitor::type type);
94 
96  std::string getDisplayByType(Monitor::type type,const unsigned int i);
97 
98  private:
99 
101 
102  typedef MMLMonitorDisplay* (*CreateMonitorDisplayFunctionPointer)(Monitor* monitor,MMLComponent* manager);
103 
105  std::map<std::string, CreateMonitorDisplayFunctionPointer> mapObjectCreator;
106 
112  template<typename C>
113  static MMLMonitorDisplay* createTheMonitorDisplay(Monitor* monitor,MMLComponent* manager){
114  return new C(monitor,manager);
115  }
116 
118  std::vector<std::string> displaysByType[Monitor::typeCount];
119 
122 };
123 
124 
125 #endif // MMLMonitorDisplayFactory_H