shawn::Processor Class Reference

Message-processing protocol resp. algorithm for nodes. More...

#include <processor.h>

Inheritance diagram for shawn::Processor:

Inheritance graph
[legend]
Collaboration diagram for shawn::Processor:

Collaboration graph
[legend]

List of all members.

Public Types

enum  ProcessorState { Active, Sleeping, Inactive }

Public Member Functions

construction / destruction
 Processor ()
virtual ~Processor ()
node membership
virtual void set_owner (Node &) throw ()
virtual const Nodeowner (void) const throw ()
virtual Nodeowner_w (void) throw ()
processor interface
virtual void special_boot (void) throw ()
virtual void boot (void) throw ()
virtual bool process_message (const ConstMessageHandle &) throw ()
virtual void work (void) throw ()
misc access
virtual int id (void) const throw ()
virtual ProcessorState state (void) const throw ()
bool auto_terminate (void) const throw ()
virtual int simulation_round (void) const throw ()
virtual void sync_to_tags (TagContainer &) throw ()
virtual void sync_from_tags (const TagContainer &) throw ( std::runtime_error )

Protected Member Functions

Message sending
virtual void send (const MessageHandle &) throw ()
State management
virtual void set_state (const ProcessorState &) throw ()
void set_auto_terminate (bool enable) throw ()


Detailed Description

Message-processing protocol resp. algorithm for nodes.

Superclass for anything that runs inside a node and processes messages. A node can contain multiple processors, eg, one for each protocol that is simulated simultaneously.

Most important methods are


Member Enumeration Documentation

Enumerator:
Active  usual state
Sleeping  message reception stopped, but work() continues
Inactive  nonrevertable death


Constructor & Destructor Documentation

shawn::Processor::Processor (  ) 

virtual shawn::Processor::~Processor (  )  [virtual]


Member Function Documentation

virtual void shawn::Processor::set_owner ( Node  )  throw () [virtual]

called by Node when processor gets added

virtual const Node& shawn::Processor::owner ( void   )  const throw () [virtual]

Returns:
const Node that contains this Processor

virtual Node& shawn::Processor::owner_w ( void   )  throw () [virtual]

Returns:
writable Node that contains this Processor

virtual void shawn::Processor::special_boot ( void   )  throw () [virtual]

This method is called once for every Processor that is contained in one special node, which is chosen arbitrarily. It can be identified by Node::is_special_node()

It is called before boot() occurs. A Processor whose special_boot() is called will still get a boot() afterwards.

virtual void shawn::Processor::boot ( void   )  throw () [virtual]

This method is called once for every Processor before the simulation starts (and again, if the simulation is reset)

virtual bool shawn::Processor::process_message ( const ConstMessageHandle &   )  throw () [virtual]

This method is called if a Node receives a Message that is to be processed. Overload this method in derived Processors to produce specific protocols/algorithms.

Returns:
true iff the Processor recognizes the passed message to be of "his own type". This makes the Node stop processing the message by passing it to all his Processors.

virtual void shawn::Processor::work ( void   )  throw () [virtual]

Called once in each simulation round. Used for periodic tasks like collecting sensor values and generating messages if someting interesting has happened.

virtual int shawn::Processor::id ( void   )  const throw () [virtual]

Returns:
the containing Node's id number
See also:
Node::id()

virtual ProcessorState shawn::Processor::state ( void   )  const throw () [virtual]

Returns:
the state of the Processor
See also:
set_state()

bool shawn::Processor::auto_terminate ( void   )  const throw ()

Returns:
See also:
set_auto_terminate()

virtual int shawn::Processor::simulation_round ( void   )  const throw () [virtual]

Returns:
the current iteration round

virtual void shawn::Processor::sync_to_tags ( TagContainer  )  throw () [virtual]

to be implemented

Implements shawn::TagSyncable.

virtual void shawn::Processor::sync_from_tags ( const TagContainer  )  throw ( std::runtime_error ) [virtual]

to be implemented

Implements shawn::TagSyncable.

virtual void shawn::Processor::send ( const MessageHandle &   )  throw () [protected, virtual]

Enqueues a message for sending. Because the message is passed as a handle (see refcnt_pointer), a construct like

  send( new MyCoolMessage(1,2,3,4) );
is fine. Whether a message is broadcast or unicast is decided by Message::is_unicast().

virtual void shawn::Processor::set_state ( const ProcessorState  )  throw () [protected, virtual]

Sets the state of the processor, where

void shawn::Processor::set_auto_terminate ( bool  enable  )  throw () [protected]

Sets the state of the processor, where


The documentation for this class was generated from the following file:

Generated on Sun Feb 5 00:01:12 2012 for Shawn by  doxygen 1.5.6