Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/new_class_id.h @ 9659

Last change on this file since 9659 was 9659, checked in by bensch, 19 years ago

some thoughts

File size: 1.2 KB
RevLine 
[4838]1/*!
[9659]2 * @file new_class_id.h
3 * @brief Definition of a dynamically allocating ClassID
4 *
5 */
[1853]6
[9659]7#ifndef _NEW_CLASS_ID_H
8#define _NEW_CLASS_ID_H
[1853]9
[9659]10#include "type_info.h"
11#include <set>
12#include <string>
[1853]13
[9659]14#define DeclareClass(ClassName) \
15   ClassIDDeclaration ClassID_##ClassName(ClassName)
[3543]16
[9659]17class ClassIDDeclaration
18{
19  friend class NewClassID;
20public:
21  ClassIDDeclaration(const std::string& name);
22  ~ClassIDDeclaration();
[3543]23
[9659]24  int id() const { return _id; };
25  const std::string& name() const { return _name; };
[2036]26
[9659]27private:
28  //! the copy constructor will be hidden.
29  ClassIDDeclaration(const ClassIDDeclaration& definer) {};
[1853]30
[9659]31private:
32  int                   _id;
33  std::string           _name;
34};
[1853]35
[3245]36
[9659]37//! A class to dynamically allocate ClassID's and support a isA operator
38class NewClassID
39{
40public:
41  NewClassID();
42  ~NewClassID();
[3245]43
[9659]44
45
46  static int classCount() { return _idCounter; };
47  static void registerClass(ClassIDDeclaration* namer);
48  static void unregisterClass(ClassIDDeclaration* namer);
49
50private:
51  std::set<ClassIDDeclaration>  _types;
52  std::string                   _className;
53
54  static int                    _idCounter;      //!< A counter, that gives all classes a Unique ClassID. Access to this Variable is to be Thread-Safe.
[1853]55};
56
[9659]57
58#endif /* _NEW_CLASS_ID_H */
Note: See TracBrowser for help on using the repository browser.