Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9659 in orxonox.OLD


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

some thoughts

Location:
trunk/src/lib
Files:
1 added
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/Makefile.am

    r9406 r9659  
    77                lang/base_object.cc \
    88                lang/class_list.cc \
     9                lang/new_class_id.cc \
    910                \
    1011                coord/p_node.cc \
  • trunk/src/lib/lang/new_class_id.cc

    r9658 r9659  
    22   orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4   Copyright (C) 2006 orx
    55
    66   This program is free software; you can redistribute it and/or modify
     
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    1616//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
    1717
    18 #include "proto_class.h"
     18#include "new_class_id.h"
     19#include <cassert>
     20
     21ClassIDDeclaration::ClassIDDeclaration(const std::string& name)
     22  : _id(-1), _name(name)
     23{
     24  NewClassID::registerClass(this);
     25}
     26
     27ClassIDDeclaration::~ClassIDDeclaration()
     28{
     29  NewClassID::unregisterClass(this);
     30}
    1931
    2032
    2133
    22 
     34///////////////////////////////////////////////////////////
     35//// CLASS ID definiton. //////////////////////////////////
     36///////////////////////////////////////////////////////////
    2337/**
    24  * standard constructor
    25  * @todo this constructor is not jet implemented - do it
    26 */
    27 ProtoClass::ProtoClass ()
     38 * @brief standard constructor
     39 */
     40NewClassID::NewClassID ()
     41  : _className("")
    2842{
    29    this->setClassID(CL_PROTO_ID, "ProtoClass");
    30 
    31    /* If you make a new class, what is most probably the case when you write this file
    32       don't forget to:
    33        1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS
    35 
    36       Advanced Topics:
    37       - if you want to let your object be managed via the ObjectManager make sure to read
    38         the object_manager.h header comments. You will use this most certanly only if you
    39         make many objects of your class, like a weapon bullet.
    40    */
    4143}
    4244
    4345
    4446/**
    45  * standard deconstructor
    46 */
    47 ProtoClass::~ProtoClass ()
     47 * @brief standard deconstructor
     48 */
     49NewClassID::~NewClassID ()
    4850{
    4951  // delete what has to be deleted here
    5052}
     53
     54
     55int NewClassID::_idCounter = 0;
     56
     57//! TODO make access to the idCounter ThreadSafe!
     58void NewClassID::registerClass(ClassIDDeclaration* namer)
     59{
     60  assert (namer->id() != -1 && "Do not register any ClassID's for yourself.");
     61
     62  namer->_id = NewClassID::_idCounter++;
     63}
     64
     65void NewClassID::unregisterClass(ClassIDDeclaration* namer)
     66{
     67  // here nothing is done, because Classes cannot be realigned fast.
     68}
  • 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 */
  • trunk/src/lib/util/smooth.h

    r9658 r9659  
    2121
    2222  //! A class to handle smoothness of Variables.
    23   /** With this smoothing can be achived for many different types of variables.
     23  /**
     24   * With this smoothing can be achived for many different types of variables.
    2425   */
    2526  template <typename var_type = float, class iteration_type = LinearIteration<var_type> > class Smooth
  • trunk/src/lib/util/timer.h

    r9658 r9659  
    1 
    21/*!
    32 * @file timer.h
     
    3332    double         _lastTime;
    3433    double         _timeStep;
    35 
    3634};
    3735
Note: See TracChangeset for help on using the changeset viewer.