DUNE: Uniform Navigational Environment  2016.03.0
DUNE::Entities::BasicEntity Class Reference

Detailed Description

Basic Entity class, handling only QueryEntityInfo/EntityInfo messages, and implementing the most basic Entity interface.

Public Member Functions

 BasicEntity (Tasks::AbstractTask *owner, Tasks::Context &context)
 
virtual ~BasicEntity ()
 
virtual void setBindings (Tasks::Recipient *recipient)
 
const std::string & getLabel (void) const
 
void setLabel (const std::string &label)
 
unsigned int getId (void) const
 
void setId (unsigned int id)
 
void reportInfo (void)
 
bool operator== (const std::string label)
 
bool operator== (unsigned int id)
 
void consume (const IMC::QueryEntityInfo *msg)
 
void dispatch (IMC::Message *msg, unsigned int flags=0)
 
void dispatch (IMC::Message &msg, unsigned int flags=0)
 
void dispatchReply (const IMC::Message &original, IMC::Message &msg, unsigned int flags=0)
 

Protected Member Functions

template<typename M , typename E >
void bind (Tasks::Recipient *recipient, E *ent_obj, void(E::*consumer)(const M *)=&E::consume)
 

Protected Attributes

Tasks::AbstractTaskm_owner
 
Tasks::Contextm_ctx
 
IMC::EntityInfo m_ent_info
 

Constructor & Destructor Documentation

DUNE::Entities::BasicEntity::BasicEntity ( Tasks::AbstractTask owner,
Tasks::Context context 
)
inline

Constructor.

Parameters
[in]ownerpointer to the task containing the entity.
[in]contextentity context.
virtual DUNE::Entities::BasicEntity::~BasicEntity ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename M , typename E >
void DUNE::Entities::BasicEntity::bind ( Tasks::Recipient recipient,
E *  ent_obj,
void(E::*)(const M *)  consumer = &E::consume 
)
inlineprotected

Bind a message to a consumer method.

Parameters
recipientrecipient object.
ent_objconsumer entity.
consumerconsumer method.

References DUNE::Tasks::Recipient::bind().

void DUNE::Entities::BasicEntity::consume ( const IMC::QueryEntityInfo msg)

Process QueryEntityInfo message.

Parameters
[in]msgpointer to QueryEntityInfo message.

References DUNE::Entities::DF_LOOP_BACK, dispatch(), dispatchReply(), DUNE::IMC::Message::getDestinationEntity(), getId(), and m_ent_info.

void DUNE::Entities::BasicEntity::dispatch ( IMC::Message msg,
unsigned int  flags = 0 
)
inline

Dispatch message to the message bus.

Parameters
[in]msgmessage reference.
[in]flagsbitfield with flags (see Tasks::DispatchFlags).

References dispatch().

void DUNE::Entities::BasicEntity::dispatchReply ( const IMC::Message original,
IMC::Message msg,
unsigned int  flags = 0 
)
inline

Dispatch message to the message bus in reply to another message.

Parameters
[in]originaloriginal message.
[in]msgmessage reference.
[in]flagsbitfield with flags (see Tasks::DispatchFlags).

References dispatch(), DUNE::IMC::Message::getSource(), DUNE::IMC::Message::getSourceEntity(), DUNE::IMC::Message::setDestination(), and DUNE::IMC::Message::setDestinationEntity().

Referenced by consume().

unsigned int DUNE::Entities::BasicEntity::getId ( void  ) const
inline
const std::string& DUNE::Entities::BasicEntity::getLabel ( void  ) const
inline
bool DUNE::Entities::BasicEntity::operator== ( const std::string  label)
inline

Compare label against a string.

Parameters
[in]labelstring to be compared against.
Returns
true if the label and the string match, false otherwise.

References getLabel().

bool DUNE::Entities::BasicEntity::operator== ( unsigned int  id)
inline

Compare id against an unsigned integer.

Parameters
[in]idinteger to use for comparison.
Returns
true if the entity id and the integer match, false otherwise.

References getId().

void DUNE::Entities::BasicEntity::reportInfo ( void  )

Report the entity information by broadcasting an EntityInfo message.

References dispatch(), and m_ent_info.

Referenced by DUNE::Tasks::Task::updateParameters().

virtual void DUNE::Entities::BasicEntity::setBindings ( Tasks::Recipient recipient)
inlinevirtual

Set the IMC bindings using the provided recipient object.

Parameters
[in]recipientpointer to the recipient object to use for binding to IMC messages.

Reimplemented in DUNE::Entities::StatefulEntity.

Referenced by DUNE::Tasks::Task::reserveEntity(), and DUNE::Entities::StatefulEntity::setBindings().

void DUNE::Entities::BasicEntity::setId ( unsigned int  id)
inline

Set the entity identifier.

Parameters
[in]identity identifier.

References DUNE::IMC::EntityInfo::id, and m_ent_info.

Referenced by DUNE::Tasks::Task::reserveEntities(), and DUNE::Tasks::Task::reserveEntity().

Member Data Documentation

Tasks::Context& DUNE::Entities::BasicEntity::m_ctx
protected

Context.

Referenced by dispatch(), and setLabel().

IMC::EntityInfo DUNE::Entities::BasicEntity::m_ent_info
protected

Entity information message.

Referenced by consume(), reportInfo(), DUNE::Entities::StatefulEntity::setActTimes(), setId(), and setLabel().

Collaboration diagram for DUNE::Entities::BasicEntity:
Collaboration graph