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 
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   
00136         virtual ~TraplasObject();
00137         int id;                                                         
00138         int type;                                               
00139         bool selected;                          
00140         string description;     
00141         osg::Node* model;               
00142         osg::Geode* label;              
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;                   
00222         string c_desc;          
00223         int carg;                                       
00224         string destination;     
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;                                           
00297         unsigned int capacity;  
00298         double distance;                                
00299         double speed;                                           
00300         int width;                                                      
00301         int height;                                                     
00302         set<int> cargoSet;              
00303         map<int, int*> arcs;            
00304 };
00305