source: src/base/object.hpp@ 48b662

Last change on this file since 48b662 was 48b662, checked in by Olaf Lenz <olenz@…>, 14 years ago

Moved files in scafacos_fcs one level up.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@847 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1021 bytes
Line 
1/**
2 * @file object.hpp
3 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
4 * @date Mon Apr 18 12:22:29 2011
5 *
6 * @brief Header file for the class VMG::Object.
7 *
8 */
9
10#ifndef OBJECT_HPP_
11#define OBJECT_HPP_
12
13#include <cassert>
14#include <string>
15
16namespace VMG
17{
18
19class Object
20{
21public:
22 Object() :
23 registered(false)
24 {}
25
26 Object(std::string name_) :
27 name(name_),
28 registered(true)
29 {
30 ObjectInit();
31 }
32
33 virtual ~Object() {}
34
35 void Register(std::string name_);
36
37 template <class T>
38 T* Cast()
39 {
40 T* casted = static_cast<T*>(this);
41 assert(casted != NULL);
42 return casted;
43 }
44
45 std::string Name() {return name;}
46
47private:
48 void ObjectInit();
49
50 std::string name;
51 bool registered;
52};
53
54template <class T>
55class ObjectStorage : public Object
56{
57public:
58 ObjectStorage(const T& val_) :
59 val(val_)
60 {}
61
62 ObjectStorage(std::string name_, const T& val_) :
63 Object(name_),
64 val(val_)
65 {}
66
67 T& Val() {return val;}
68
69private:
70 T val;
71};
72
73}
74
75#endif /* OBJECT_HPP_ */
Note: See TracBrowser for help on using the repository browser.