COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
VrbRegistry.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 #ifndef VrbRegistry_h
8 #define VrbRegistry_h
9 
10 #include "regClass.h"
11 #include <boost/filesystem.hpp>
12 #include <fstream>
13 #include <ctime>
14 
15 namespace vrb
16 {
17 template <class ClassType, class VarType>
19 {
20 protected:
21  std::map<const std::string, std::shared_ptr<ClassType>> myClasses;
22 
24  void readClass(std::ifstream &file)
25  {
26  std::string className, delimiter, space;
27  file >> className;
28  file >> space;
29  std::shared_ptr<ClassType> cl = createClass(className, -1); // -1 = nobodies client ID
30  myClasses[className] = cl;
31  cl->readVar(file);
32  }
33 
34  void clearRegistry() {
35  //delete all entries and inform their observers
36  }
37 
38 public:
39 
40  virtual int getID() = 0;
41  virtual std::shared_ptr<ClassType> createClass(const std::string &name, int id) = 0;
42  void loadRegistry(std::ifstream &inFile) {
43 
44  while (!inFile.eof())
45  {
46  readClass(inFile);
47  }
48 
49  }
50 
51  void saveRegistry(std::ofstream &outFile) const {
52  for (const auto &cl : myClasses)
53  {
54  outFile << "\n";
55  cl.second->writeClass(outFile);
56  }
57  }
58 };
59 }
60 #endif // !VrbRegistry_h
std::map< const std::string, std::shared_ptr< ClassType > > myClasses
Definition: VrbRegistry.h:21
void loadRegistry(std::ifstream &inFile)
Definition: VrbRegistry.h:42
GLsizei const GLchar *const * string
Definition: khronos-glext.h:6750
void saveRegistry(std::ofstream &outFile) const
Definition: VrbRegistry.h:51
void readClass(std::ifstream &file)
changes name to the read name and return the char which contains the classes variables ...
Definition: VrbRegistry.h:24
GLuint const GLchar * name
Definition: khronos-glext.h:6722
virtual int getID()=0
void clearRegistry()
Definition: VrbRegistry.h:34
virtual std::shared_ptr< ClassType > createClass(const std::string &name, int id)=0
Definition: VrbRegistry.h:18