Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9659 in orxonox.OLD for trunk/src/lib/lang/new_class_id.h


Ignore:
Timestamp:
Aug 15, 2006, 9:35:58 PM (19 years ago)
Author:
bensch
Message:

some thoughts

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/new_class_id.h

    r9658 r9659  
    11/*!
    2  * @file proto_class.h
    3  * @brief Definition of ...
    4 */
     2 * @file new_class_id.h
     3 * @brief Definition of a dynamically allocating ClassID
     4 *
     5 */
    56
    6 #ifndef _PROTO_CLASS_H
    7 #define _PROTO_CLASS_H
     7#ifndef _NEW_CLASS_ID_H
     8#define _NEW_CLASS_ID_H
    89
    9 #include "base_object.h"
     10#include "type_info.h"
     11#include <set>
     12#include <string>
    1013
    11 // FORWARD DECLARATION
     14#define DeclareClass(ClassName) \
     15   ClassIDDeclaration ClassID_##ClassName(ClassName)
     16
     17class ClassIDDeclaration
     18{
     19  friend class NewClassID;
     20public:
     21  ClassIDDeclaration(const std::string& name);
     22  ~ClassIDDeclaration();
     23
     24  int id() const { return _id; };
     25  const std::string& name() const { return _name; };
     26
     27private:
     28  //! the copy constructor will be hidden.
     29  ClassIDDeclaration(const ClassIDDeclaration& definer) {};
     30
     31private:
     32  int                   _id;
     33  std::string           _name;
     34};
     35
     36
     37//! A class to dynamically allocate ClassID's and support a isA operator
     38class NewClassID
     39{
     40public:
     41  NewClassID();
     42  ~NewClassID();
    1243
    1344
    1445
    15 //! A class for ...
    16 class ProtoClass : public BaseObject {
     46  static int classCount() { return _idCounter; };
     47  static void registerClass(ClassIDDeclaration* namer);
     48  static void unregisterClass(ClassIDDeclaration* namer);
    1749
    18  public:
    19   ProtoClass();
    20   virtual ~ProtoClass();
     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.
     55};
    2156
    2257
    23  private:
    24 
    25 };
    26 
    27 #endif /* _PROTO_CLASS_H */
     58#endif /* _NEW_CLASS_ID_H */
Note: See TracChangeset for help on using the changeset viewer.