DUNE: Uniform Navigational Environment  2.6.0-rc4
Transports::SUNSET::AbstractCommand Class Referenceabstract

Public Types

enum  Flags { FLAG_LAST }
 
enum  Offset {
  OFFS_PREFIX, OFFS_VERSION, OFFS_FLAGS, OFFS_TTL,
  OFFS_PRIORITY, OFFS_SRC, OFFS_DST_COUNT, OFFS_DST,
  OFFS_LAST
}
 

Public Member Functions

 AbstractCommand (void)
 
 AbstractCommand (const std::string &name, unsigned version=0)
 
virtual ~AbstractCommand (void)
 
void clear (void)
 
AbstractCommandsetVersion (unsigned version)
 
unsigned getVersion (void) const
 
AbstractCommandsetName (const std::string &name)
 
std::string getName (void) const
 
AbstractCommandsetSource (unsigned addr)
 
unsigned getSource (void) const
 
AbstractCommandsetDestination (unsigned addr)
 
AbstractCommandclearDestination (unsigned addr)
 
const std::set< unsigned > & getDestinations (void) const
 
AbstractCommandsetDestinations (const std::set< unsigned > &dsts)
 
AbstractCommandsetTTL (unsigned value)
 
unsigned getTTL (void) const
 
AbstractCommandsetFlags (unsigned value)
 
unsigned getFlags (void) const
 
AbstractCommandsetPriority (unsigned value)
 
unsigned getPriority (void) const
 
std::string encode (void) const
 
void toText (std::ostream &os) const
 
bool operator== (const AbstractCommand &b) const
 
bool operator!= (const AbstractCommand &b) const
 
virtual size_t encodeArgs (std::vector< std::string > &args) const =0
 
virtual size_t decodeArgs (const std::vector< std::string > &args, size_t index)=0
 
virtual void toTextArgs (std::ostream &os__) const =0
 

Static Public Member Functions

static uint16_t getCRC (const std::string &cmd)
 
static uint16_t computeCRC (const std::string &str, size_t size)
 
static std::string getFlagList (unsigned flags)
 

Member Enumeration Documentation

Command flags.

Enumerator
FLAG_LAST 
Enumerator
OFFS_PREFIX 

Prefix.

OFFS_VERSION 

Version.

OFFS_FLAGS 

Flags.

OFFS_TTL 

Time-to-live.

OFFS_PRIORITY 

Priority.

OFFS_SRC 

Source.

OFFS_DST_COUNT 

Number of destinations.

OFFS_DST 

First destination.

OFFS_LAST 

Last fixed offset.

Constructor & Destructor Documentation

Transports::SUNSET::AbstractCommand::AbstractCommand ( void  )
inline

Default constructor.

Transports::SUNSET::AbstractCommand::AbstractCommand ( const std::string &  name,
unsigned  version = 0 
)
inline

Construct a Command object setting name and version.

Parameters
[in]namecommand name.
[in]versioncommand version.
virtual Transports::SUNSET::AbstractCommand::~AbstractCommand ( void  )
inlinevirtual

Member Function Documentation

void Transports::SUNSET::AbstractCommand::clear ( void  )
inline

Clear command.

AbstractCommand& Transports::SUNSET::AbstractCommand::clearDestination ( unsigned  addr)
inline

Remove destination address.

This function can be called multiple times to remove more than one destination address.

Parameters
[in]addrdestination address.
Returns
command object.
static uint16_t Transports::SUNSET::AbstractCommand::computeCRC ( const std::string &  str,
size_t  size 
)
inlinestatic

Compute the CRC of a string fragment.

Parameters
[in]strstring.
[in]sizestring size.
Returns
CRC value.

References DUNE::Algorithms::CRC16::compute().

Referenced by Transports::SUNSET::Factory::decode(), and encode().

std::string Transports::SUNSET::AbstractCommand::encode ( void  ) const
inline

Encode object to text form.

Returns
command in text form.

References computeCRC(), encodeArgs(), DUNE::Utils::String::join(), and DUNE::Utils::String::str().

Referenced by Transports::SUNSET::Task::sendCommand().

static uint16_t Transports::SUNSET::AbstractCommand::getCRC ( const std::string &  cmd)
inlinestatic

Retrieve CRC from an encoded command string.

Parameters
[in]cmdcommand string.
Returns
CRC value.

Referenced by Transports::SUNSET::Factory::decode().

const std::set<unsigned>& Transports::SUNSET::AbstractCommand::getDestinations ( void  ) const
inline

Retrieve destination addresses.

Returns
destination addresses.
static std::string Transports::SUNSET::AbstractCommand::getFlagList ( unsigned  flags)
inlinestatic

Retrieve human-readable list of flags.

Parameters
[in]flagsflags bitfield.
Returns
human-readable list of flags.

References DUNE::Utils::String::join().

Referenced by toText().

unsigned Transports::SUNSET::AbstractCommand::getFlags ( void  ) const
inline

Retrieve command flags.

Returns
command flags.
std::string Transports::SUNSET::AbstractCommand::getName ( void  ) const
inline

Get command name.

Returns
command name.

Referenced by Transports::SUNSET::Task::handleCommand(), and Transports::SUNSET::Task::handleSensorSampleGet().

unsigned Transports::SUNSET::AbstractCommand::getPriority ( void  ) const
inline

Retrieve command priority.

Returns
command priority.
unsigned Transports::SUNSET::AbstractCommand::getTTL ( void  ) const
inline

Retrieve command time-to-live.

Returns
command time-to-live in seconds.
unsigned Transports::SUNSET::AbstractCommand::getVersion ( void  ) const
inline

Get command version.

Returns
command version.
bool Transports::SUNSET::AbstractCommand::operator!= ( const AbstractCommand b) const
inline
bool Transports::SUNSET::AbstractCommand::operator== ( const AbstractCommand b) const
inline
AbstractCommand& Transports::SUNSET::AbstractCommand::setDestinations ( const std::set< unsigned > &  dsts)
inline

Set destination addresses.

Returns
command object.

Referenced by Transports::SUNSET::Factory::decode().

AbstractCommand& Transports::SUNSET::AbstractCommand::setFlags ( unsigned  value)
inline

Set command flags.

Parameters
[in]valueflags.
Returns
command object.

Referenced by Transports::SUNSET::Factory::decode().

AbstractCommand& Transports::SUNSET::AbstractCommand::setName ( const std::string &  name)
inline

Set command name.

Parameters
[in]namecommand name.
Returns
command object.

Referenced by Transports::SUNSET::Abort::Abort(), Transports::SUNSET::Aborted::Aborted(), Transports::SUNSET::CommandError::CommandError(), Transports::SUNSET::CommandFailure::CommandFailure(), Transports::SUNSET::CommandOk::CommandOk(), Transports::SUNSET::Factory::decode(), Transports::SUNSET::PacketRx::PacketRx(), Transports::SUNSET::PacketTx::PacketTx(), Transports::SUNSET::PacketTxStatus::PacketTxStatus(), Transports::SUNSET::Param::Param(), Transports::SUNSET::ParamGet::ParamGet(), Transports::SUNSET::ParamSet::ParamSet(), Transports::SUNSET::Plan::Plan(), Transports::SUNSET::PlanAdd::PlanAdd(), Transports::SUNSET::PlanAdded::PlanAdded(), Transports::SUNSET::PlanDelete::PlanDelete(), Transports::SUNSET::PlanDeleted::PlanDeleted(), Transports::SUNSET::PlanGet::PlanGet(), Transports::SUNSET::PlanList::PlanList(), Transports::SUNSET::PlanListGet::PlanListGet(), Transports::SUNSET::PlanStart::PlanStart(), Transports::SUNSET::PlanStarted::PlanStarted(), Transports::SUNSET::PlanStop::PlanStop(), Transports::SUNSET::PlanStopped::PlanStopped(), Transports::SUNSET::Position::Position(), Transports::SUNSET::PositionGet::PositionGet(), Transports::SUNSET::Range::Range(), Transports::SUNSET::RangeGet::RangeGet(), Transports::SUNSET::SensorInfo::SensorInfo(), Transports::SUNSET::SensorInfoGet::SensorInfoGet(), Transports::SUNSET::SensorList::SensorList(), Transports::SUNSET::SensorListGet::SensorListGet(), Transports::SUNSET::SensorSample::SensorSample(), and Transports::SUNSET::SensorSampleGet::SensorSampleGet().

AbstractCommand& Transports::SUNSET::AbstractCommand::setPriority ( unsigned  value)
inline

Set command priority.

Parameters
[in]valuepriority.
Returns
command object.

Referenced by Transports::SUNSET::Factory::decode().

AbstractCommand& Transports::SUNSET::AbstractCommand::setSource ( unsigned  addr)
inline
AbstractCommand& Transports::SUNSET::AbstractCommand::setTTL ( unsigned  value)
inline

Set command time-to-live.

Parameters
[in]valuenumber of seconds.
Returns
command object.

Referenced by Transports::SUNSET::Factory::decode().

AbstractCommand& Transports::SUNSET::AbstractCommand::setVersion ( unsigned  version)
inline

Set command version.

Parameters
[in]versioncommand version.
Returns
command object.

Referenced by Transports::SUNSET::Factory::decode().

void Transports::SUNSET::AbstractCommand::toText ( std::ostream &  os) const
inline

References getFlagList(), and toTextArgs().

Collaboration diagram for Transports::SUNSET::AbstractCommand:
Collaboration graph