ARGoS  3
A parallel, multi-engine simulator for swarm robotics
plugins/simulator/entities/led_entity.h
Go to the documentation of this file.
00001 
00007 #ifndef LED_ENTITY_H
00008 #define LED_ENTITY_H
00009 
00010 namespace argos {
00011    class CLEDEntity;
00012    class CLEDMedium;
00013 }
00014 
00015 #include <argos3/core/simulator/entity/positional_entity.h>
00016 #include <argos3/core/utility/datatypes/set.h>
00017 #include <argos3/core/utility/datatypes/color.h>
00018 #include <argos3/core/utility/math/vector3.h>
00019 #include <argos3/core/simulator/space/positional_indices/space_hash.h>
00020 #include <argos3/core/simulator/space/positional_indices/grid.h>
00021 
00022 namespace argos {
00023 
00024    class CLEDEntity : public CPositionalEntity {
00025 
00026    public:
00027 
00028       ENABLE_VTABLE();
00029 
00030       typedef std::vector<CLEDEntity*> TList;
00031       typedef CSet<CLEDEntity*> TSet;
00032 
00033    public:
00034 
00035       CLEDEntity(CComposableEntity* pc_parent);
00036 
00037       CLEDEntity(CComposableEntity* pc_parent,
00038                  const std::string& str_id,
00039                  const CVector3& c_position,
00040                  const CColor& c_color);
00041 
00042       virtual ~CLEDEntity() {}
00043 
00044       virtual void Init(TConfigurationNode& t_tree);
00045 
00046       virtual void Reset();
00047 
00048       virtual void SetEnabled(bool b_enabled);
00049 
00056       inline const CColor& GetColor() const {
00057          return m_cColor;
00058       }
00059 
00067       inline const CColor& GetInitColor() const {
00068          return m_cInitColor;
00069       }
00070 
00076       inline void SetColor(const CColor& c_color) {
00077          m_cColor = c_color;
00078       }
00079 
00087       inline void SetInitColor(const CColor& c_color) {
00088          m_cInitColor = c_color;
00089       }
00090 
00091       virtual std::string GetTypeDescription() const {
00092          return "led";
00093       }
00094 
00100       void AddToMedium(CLEDMedium& c_medium);
00101 
00107       void RemoveFromMedium(CLEDMedium& c_medium);
00108 
00109    protected:
00110 
00111       CColor m_cColor;
00112       CColor m_cInitColor;
00113 
00114    };
00115 
00116    /****************************************/
00117    /****************************************/
00118 
00119    class CLEDEntitySpaceHashUpdater : public CSpaceHashUpdater<CLEDEntity> {
00120 
00121    public:
00122 
00123       virtual void operator()(CAbstractSpaceHash<CLEDEntity>& c_space_hash,
00124                               CLEDEntity& c_element);
00125 
00126    private:
00127 
00128       SInt32 m_nI, m_nJ, m_nK;
00129 
00130    };
00131 
00132    /****************************************/
00133    /****************************************/
00134 
00135    class CLEDEntityGridUpdater : public CGrid<CLEDEntity>::COperation {
00136 
00137    public:
00138 
00139       CLEDEntityGridUpdater(CGrid<CLEDEntity>& c_grid);
00140       virtual bool operator()(CLEDEntity& c_entity);
00141 
00142    private:
00143 
00144       CGrid<CLEDEntity>& m_cGrid;
00145       SInt32 m_nI, m_nJ, m_nK;
00146 
00147    };
00148 
00149    /****************************************/
00150    /****************************************/
00151 
00152 }
00153 
00154 #endif