- Timestamp:
- Aug 15, 2006, 9:35:58 PM (18 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 1 added
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/Makefile.am
r9406 r9659 7 7 lang/base_object.cc \ 8 8 lang/class_list.cc \ 9 lang/new_class_id.cc \ 9 10 \ 10 11 coord/p_node.cc \ -
trunk/src/lib/lang/new_class_id.cc
r9658 r9659 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 Copyright (C) 200 4orx4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 */ … … 16 16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 17 17 18 #include "proto_class.h" 18 #include "new_class_id.h" 19 #include <cassert> 20 21 ClassIDDeclaration::ClassIDDeclaration(const std::string& name) 22 : _id(-1), _name(name) 23 { 24 NewClassID::registerClass(this); 25 } 26 27 ClassIDDeclaration::~ClassIDDeclaration() 28 { 29 NewClassID::unregisterClass(this); 30 } 19 31 20 32 21 33 22 34 /////////////////////////////////////////////////////////// 35 //// CLASS ID definiton. ////////////////////////////////// 36 /////////////////////////////////////////////////////////// 23 37 /** 24 * standard constructor25 * @todo this constructor is not jet implemented - do it26 */ 27 ProtoClass::ProtoClass ()38 * @brief standard constructor 39 */ 40 NewClassID::NewClassID () 41 : _className("") 28 42 { 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 file32 don't forget to:33 1. Add the new file new_class.cc to the ./src/Makefile.am34 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS35 36 Advanced Topics:37 - if you want to let your object be managed via the ObjectManager make sure to read38 the object_manager.h header comments. You will use this most certanly only if you39 make many objects of your class, like a weapon bullet.40 */41 43 } 42 44 43 45 44 46 /** 45 * standard deconstructor46 */47 ProtoClass::~ProtoClass()47 * @brief standard deconstructor 48 */ 49 NewClassID::~NewClassID () 48 50 { 49 51 // delete what has to be deleted here 50 52 } 53 54 55 int NewClassID::_idCounter = 0; 56 57 //! TODO make access to the idCounter ThreadSafe! 58 void 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 65 void 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 1 1 /*! 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 */ 5 6 6 #ifndef _ PROTO_CLASS_H7 #define _ PROTO_CLASS_H7 #ifndef _NEW_CLASS_ID_H 8 #define _NEW_CLASS_ID_H 8 9 9 #include "base_object.h" 10 #include "type_info.h" 11 #include <set> 12 #include <string> 10 13 11 // FORWARD DECLARATION 14 #define DeclareClass(ClassName) \ 15 ClassIDDeclaration ClassID_##ClassName(ClassName) 16 17 class ClassIDDeclaration 18 { 19 friend class NewClassID; 20 public: 21 ClassIDDeclaration(const std::string& name); 22 ~ClassIDDeclaration(); 23 24 int id() const { return _id; }; 25 const std::string& name() const { return _name; }; 26 27 private: 28 //! the copy constructor will be hidden. 29 ClassIDDeclaration(const ClassIDDeclaration& definer) {}; 30 31 private: 32 int _id; 33 std::string _name; 34 }; 35 36 37 //! A class to dynamically allocate ClassID's and support a isA operator 38 class NewClassID 39 { 40 public: 41 NewClassID(); 42 ~NewClassID(); 12 43 13 44 14 45 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); 17 49 18 public: 19 ProtoClass(); 20 virtual ~ProtoClass(); 50 private: 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 }; 21 56 22 57 23 private: 24 25 }; 26 27 #endif /* _PROTO_CLASS_H */ 58 #endif /* _NEW_CLASS_ID_H */ -
trunk/src/lib/util/smooth.h
r9658 r9659 21 21 22 22 //! 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. 24 25 */ 25 26 template <typename var_type = float, class iteration_type = LinearIteration<var_type> > class Smooth -
trunk/src/lib/util/timer.h
r9658 r9659 1 2 1 /*! 3 2 * @file timer.h … … 33 32 double _lastTime; 34 33 double _timeStep; 35 36 34 }; 37 35
Note: See TracChangeset
for help on using the changeset viewer.