Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

include/TraplasObject.h

Go to the documentation of this file.
00001 
00017 #define STATECONTROL_H
00018 
00019 #ifndef _STDLIB_H
00020 #include <stdlib.h>
00021 #endif
00022 
00023 #ifndef _STDIO_H
00024 #include <stdio.h>
00025 #endif
00026 
00027 #ifndef _GLIBCXX_VECTOR
00028 #include <vector>
00029 #endif
00030 
00031 #ifndef _GLIBCXX_MAP
00032 #include <map>
00033 #endif
00034 
00035 #ifndef _GLIBCXX_STRING
00036 #include <string>
00037 #endif
00038 
00039 #ifndef _PTHREAD_H
00040 #include <pthread.h>
00041 #endif
00042 
00043 #ifndef OSG_REFERENCED
00044 #include <osg/Referenced>
00045 #endif
00046 
00047 #ifndef OSG_GROUP
00048 #include <osg/Group>
00049 #endif
00050 
00051 #ifndef OSG_NODE
00052 #include <osg/Node>
00053 #endif
00054 
00055 #ifndef OSG_ANIMATIONPATH
00056 #include <osg/AnimationPath>
00057 #endif
00058 
00059 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
00060 #include <boost/shared_ptr.hpp>
00061 #endif
00062 
00063 //forward declaration.
00064 class Dispatcher;
00065 
00066 using namespace boost;
00067 using namespace std; 
00068 
00069 #define CARGO 0
00070 #define TRANSPORT 1
00071 #define LOCATION 2
00072 
00073 
00079 class TraplasObject:public osg::Referenced{
00080         public:
00081         TraplasObject();
00086         inline virtual int getId(){return id;}
00091         inline virtual int getType(){return type;}
00096         virtual void setDescription(string descript);
00101         virtual bool select();
00106         inline virtual bool isSelected(){return selected;}
00111         inline virtual osg::Node* getModel(){return model;}
00116         virtual osg::Vec3d getPosition();
00120   virtual string toString();
00127         bool setLabel(shared_ptr<string> desc);
00133         void initLabel();
00134         protected:
00135   /* The destructor is protected because this class inherets from osg::Referenced. This enables a kind of shared pointers functionality so we won't have to worry much about memory management. */
00136         virtual ~TraplasObject();
00137         int id;                                                         //the ID of the object in Traplas. used by statecontrol to manage objects.
00138         int type;                                               //the type of object. Can be TRANSPORT, CARGO or LOCATION.
00139         bool selected;                          //whether or not this object is currently selected.
00140         string description;     //The description of the object as given by Traplas.
00141         osg::Node* model;               //reference to the model that represents this object in the visualisation.
00142         osg::Geode* label;              //The text label that is visible over all objects.
00143 };
00144 
00150 class Cargo:public TraplasObject{
00151         public:
00159         Cargo(int carg_id, int type_carg, osg::Node* carg_model);
00163         string toString();
00164 };
00165 
00169 class Transport:public TraplasObject{
00170         public:
00179         Transport(int transport_id, int type_transport, double spd, osg::Node* trans_model);
00183         inline double getSpeed(){return speed;}
00189         bool setSpeed(double s_spd);
00193         inline string getDestination(){return destination;}
00199         bool setDestination(string s_dest);
00203         inline int getCargo(){return carg;}
00210         bool setCargo(int s_carg, string desc);
00215         int clearCargo();
00219   string toString();
00220         protected:
00221         double speed;                   //the speed at which this transport is driving.
00222         string c_desc;          //The description of the cargo that is currently loaded.
00223         int carg;                                       //The traplas id of the cargo currently loaded.
00224         string destination;     //The final destination of this transport.
00225 };
00226 
00232 class Infrastructure:public TraplasObject{
00233         public:
00245         Infrastructure(int infrastructure_id, int type_infrastructure, double spd, int tile_type, unsigned int cap, double dist, osg::Node* infra_model);
00251         bool addCarg(int a_carg);
00257         int removeCarg(int r_carg);
00261         inline int getTileType(){return tileType;}
00265         inline double getSpeed(){return speed;}
00271         bool setSpeed(double s_spd);
00275         inline unsigned int getCapacity(){return capacity;}
00279         inline double getDistance(){return distance;}
00285         bool addArc(int to);
00290         bool isArc(int end);
00294   virtual string toString();
00295         protected:
00296         int tileType;                                           //What tile is used to represent this infrastructure resource. See the dbus interface specification, appendix B.
00297         unsigned int capacity;  //The maximum amount of transports that can drive through this location at one time.
00298         double distance;                                //distance.
00299         double speed;                                           //The maximum speed at this location.
00300         int width;                                                      //The width of this tile. Used for scaling.
00301         int height;                                                     //""  height "" "" "".
00302         set<int> cargoSet;              //The cargo that is at this location.
00303         map<int, int*> arcs;            //one-directional arcs to the locations that are adjacent to and reachable from this one.
00304 };
00305 

Generated on Mon Jun 19 10:22:04 2006 for TraplasVisualisation by  doxygen 1.4.4