User Manual, Developers Guide and API Documentation

wns::ldk::CommandProxy Class Reference
[Command Provider Interface]

Manage Commands within a CommandPool and make them accessible. More...

#include <ldk/CommandProxy.hpp>

Collaboration diagram for wns::ldk::CommandProxy:

Collaboration graph
[legend]

List of all members.

Public Types

typedef unsigned long int CommandIDType

Public Member Functions

CommandactivateCommand (CommandPool *commandPool, const CommandIDType &id)
 Activate and return a Command.
void addFunctionalUnit (const std::string &commandName, CommandTypeSpecifierInterface *functionalUnit)
 Add a CommandTypeSpecifier with a certain role name.
void calculateSizes (const CommandPool *commandPool, Bit &commandPoolSize, Bit &sduSize, const CommandTypeSpecifierInterface *questioner=NULL) const
 Calculate the size of a PDU from a given point of view.
bool commandIsActivated (const CommandPool *commandPool, const CommandIDType &id) const
bool commandIsActivated (const CommandPool *commandPool, const CommandTypeSpecifierInterface *kind) const
 Return true if the given Command is activated.
 CommandProxy (const wns::pyconfig::View &config)
 CommandProxy ()
void commitSizes (CommandPool *commandPool, const CommandIDType &id) const
 Commit the current sizes.
void commitSizes (CommandPool *commandPool, const CommandTypeSpecifierInterface *commiter=NULL) const
void copy (CommandPool *dst, const CommandPool *src) const
 Copy the content a CommandPool to another CommandPool.
CommandPoolcreateCommandPool (const fun::FUN *origin=NULL) const
 Create a fresh CommandPool for the Functional Unit Network.
CommandPoolcreateReply (const CommandPool *original, const CommandTypeSpecifierInterface *questioner) const
 Ask functional units to create a reply for their PCIs.
template<typename COMMANDTYPE>
COMMANDTYPE * getCommand (const CommandPool *commandPool, const std::string &role) const
 Return a reference to a Command instance within a CommandPool.
CommandgetCommand (const CommandPool *commandPool, CommandIDType n) const
 Return the nth Command within a CommandPool.
CommandgetCommand (const CommandPool *commandPool, const CommandTypeSpecifierInterface *kind) const
 Return a reference to a Command instance within a CommandPool.
size_t getCommandObjSize (const CommandIDType &id) const
CommandReaderInterfacegetCommandReader (const std::string &role) const
 Return a reference to a Command Reader for the given commandName.
void partialCopy (const CommandTypeSpecifierInterface *initiator, CommandPool *dst, const CommandPool *src) const
 Perform a partial copy of the content of a CommandPool to another CommandPool.
std::string printCommandIDRegistryKeys ()
 Show list of all known command names.
void removeFunctionalUnit (const std::string &commandName)
 Remove a CommandTypeSpecifier.
 ~CommandProxy ()

Static Public Member Functions

static CommandactivateCommand (CommandPool *commandPool, const CommandTypeSpecifierInterface *kind)
 Activate and return a Command.
static void clearRegistries ()
 This method should ONLY be used from within unitTests.

Private Types

typedef std::vector< boolBoolContainer
 Container for bool.
typedef
wns::container::Registry
< std::string, CommandIDType
CommandIDRegistry
 Mapping of role name to CommandIDType.
typedef
wns::container::Registry
< CommandIDType,
CommandReaderInterface
*, wns::container::registry::DeleteOnErase
CommandReaderRegistry
 Mapping of CommandIDType to cloned CopyCommand Object.
typedef std::vector
< CommandTypeSpecifierInterface * > 
CommandTypeSpecifierContainer
 Container for CommandTypeSpecifiers.
typedef
wns::container::Registry
< CommandIDType,
CopyCommandInterface
*, wns::container::registry::DeleteOnErase
CopyCommandInterfaceRegistry
 Mapping of CommandIDType to cloned CommandTypeSpecifier.

Private Member Functions

void cleanup (CommandPool *commandPool) const
 Call destructors of Commands within the CommandPool.
wns::ldk::Commandcommit (CommandPool *commandPool, const CommandTypeSpecifierInterface *commiter=NULL) const
const
CommandTypeSpecifierInterface
getCommandTypeSpecifier (CommandIDType id) const
 Returns a CommandTypeSpecifier according to its ID.
const
CommandTypeSpecifierInterface
getNext (const CommandPool *commandPool, const CommandTypeSpecifierInterface *questioner) const
 Returns the CommandTypeSpecifier above the questioner.

Static Private Member Functions

static std::string dumpCommandIDRegistry ()
static CommandIDRegistrygetCommandIDRegistry ()
static CommandReaderRegistrygetCommandReaderRegistry ()
static
CopyCommandInterfaceRegistry
getCopyCommandRegistry ()

Private Attributes

BoolContainer commandTypeSpecifierCloned
CommandTypeSpecifierContainer commandTypeSpecifiers
wns::logger::Logger logger

Static Private Attributes

static CommandIDType serial = CommandIDType(0)

Friends

class CommandPool
class CommandReaderInterface


Detailed Description

Author:
Fabian Debus <fds@comnets.rwth-aachen.de>
Every Functional Unit Network has a CommandProxy that encapsulates the knowledge about the layout of Commands within a CommandPool.

Note:
For a discussion on why the current design is not optimal see CommandProxy.hpp

Definition at line 63 of file CommandProxy.hpp.


Member Typedef Documentation

typedef std::vector<bool> wns::ldk::CommandProxy::BoolContainer [private]

Definition at line 90 of file CommandProxy.hpp.

Definition at line 96 of file CommandProxy.hpp.

Definition at line 66 of file CommandProxy.hpp.

Definition at line 102 of file CommandProxy.hpp.

Definition at line 84 of file CommandProxy.hpp.

Definition at line 108 of file CommandProxy.hpp.


Constructor & Destructor Documentation

wns::ldk::CommandProxy::CommandProxy (  )  [inline]

Definition at line 113 of file CommandProxy.hpp.

CommandProxy::CommandProxy ( const wns::pyconfig::View config  ) 

Definition at line 42 of file CommandProxy.cpp.

CommandProxy::~CommandProxy (  ) 

Definition at line 49 of file CommandProxy.cpp.


Member Function Documentation

Command * CommandProxy::activateCommand ( CommandPool commandPool,
const CommandIDType id 
)

Commands can only get activated once. Activating a Command twice will cause the program to abort.

Definition at line 264 of file CommandProxy.cpp.

wns::ldk::Command * CommandProxy::activateCommand ( CommandPool commandPool,
const CommandTypeSpecifierInterface kind 
) [static]

Commands can only get activated once. Activating a Command twice will cause the program to abort.

Definition at line 237 of file CommandProxy.cpp.

void CommandProxy::addFunctionalUnit ( const std::string &  commandName,
CommandTypeSpecifierInterface functionalUnit 
)

Precondition:
Functional Unit must be registered at a FUN
This makes a Functional Unit known to the CommandProxy and the global CommandIDRegistry with its role name.

Definition at line 63 of file CommandProxy.cpp.

void CommandProxy::calculateSizes ( const CommandPool commandPool,
Bit commandPoolSize,
Bit sduSize,
const CommandTypeSpecifierInterface questioner = NULL 
) const

Every FunctionalUnit in a Layer stack may mutate the PDU it receives and change its sizes (PCI and SDU size). Thus if you ask for the size of a PDU, the answer may depend on the position and kind of the FunctionalUnit you ask.

Every FunctionalUnit in turn only knows how to calculate the sizes of a PDU based on the sizes the next higher FunctionalUnit provides.

To ask for the sizes of a PDU, you may provide a FunctionalUnit as questioner to describe the point of view. The answer will be the sizes as calculated by the FunctionalUnit right above the questioner.

Note:
Internally, CommandProxy simply delegates the size calculation request to the FunctionalUnit right above the questioner (using CommandTypeSpecifierInterface::calculateSizes). The FunctionalUnit in turn may choose to delegate the size calculation request back to the proxy with itself as questioner.

Definition at line 329 of file CommandProxy.cpp.

void CommandProxy::cleanup ( CommandPool commandPool  )  const [private]

Definition at line 457 of file CommandProxy.cpp.

void CommandProxy::clearRegistries (  )  [static]

It resets the static registries administered in the CommandProxy to avoid name clashes when different tests register different commandTypeSpecifiers under the same commandName.

Definition at line 552 of file CommandProxy.cpp.

bool CommandProxy::commandIsActivated ( const CommandPool commandPool,
const CommandIDType id 
) const

Definition at line 227 of file CommandProxy.cpp.

bool CommandProxy::commandIsActivated ( const CommandPool commandPool,
const CommandTypeSpecifierInterface kind 
) const

If in doubt, do not use this method. A real protocol implementation has no means of retrieving such information. The protocol has to provide enough information to infer whether a command is activated.

Definition at line 217 of file CommandProxy.cpp.

wns::ldk::Command * CommandProxy::commit ( CommandPool commandPool,
const CommandTypeSpecifierInterface commiter = NULL 
) const [private]

Definition at line 437 of file CommandProxy.cpp.

void CommandProxy::commitSizes ( CommandPool commandPool,
const CommandIDType id 
) const

Definition at line 431 of file CommandProxy.cpp.

void CommandProxy::commitSizes ( CommandPool commandPool,
const CommandTypeSpecifierInterface commiter = NULL 
) const

Definition at line 379 of file CommandProxy.cpp.

void CommandProxy::copy ( CommandPool dst,
const CommandPool src 
) const

Definition at line 464 of file CommandProxy.cpp.

CommandPool * CommandProxy::createCommandPool ( const fun::FUN origin = NULL  )  const

A CommandPool contains the Commands of all Functional Units registered at the CommandProxy.

The returned CommandPool has a reference count of 0.

Definition at line 275 of file CommandProxy.cpp.

CommandPool * CommandProxy::createReply ( const CommandPool original,
const CommandTypeSpecifierInterface questioner 
) const

Some functional units need to send a reply to their peer-entity, but they have no information on how routing of compounds is done, since routing may need partial modification of the Commands of other functional units.

One example for such a FunctionalUnit is an ARQ implementation, that needs to inject ACK compounds back into the stack. It does not have any information itself on how to send a PDU to the originator of the received PDU.

createReply asks the CommandProxy to create a PCI as a reply to the original CommandPool for the questioner. The CommandProxy itself will ask the FunctionalUnit which activated its Command before the questioner to create a reply (which in turn could ask the proxy and so on).

If none of the functional units allocated a new CommandPool, the proxy, when asked by the FunctionalUnit which activated its Command at first, will create a CommandPool. This CommandPool will then be passed back through all the createReply calls and each of the involved functional units should activate the Command and fill it accordingly to make it a reply to the original Command.

Definition at line 315 of file CommandProxy.cpp.

std::string CommandProxy::dumpCommandIDRegistry (  )  [static, private]

Definition at line 524 of file CommandProxy.cpp.

template<typename COMMANDTYPE>
COMMANDTYPE* wns::ldk::CommandProxy::getCommand ( const CommandPool commandPool,
const std::string &  role 
) const [inline]

Only activated commands may be retrieved. Trying to retrieve a Command that has not been activated causes the program to abort.

Definition at line 261 of file CommandProxy.hpp.

wns::ldk::Command * CommandProxy::getCommand ( const CommandPool commandPool,
CommandIDType  n 
) const

Definition at line 192 of file CommandProxy.cpp.

wns::ldk::Command * CommandProxy::getCommand ( const CommandPool commandPool,
const CommandTypeSpecifierInterface kind 
) const

Only activated commands may be retrieved. Trying to retrieve a Command that has not been activated causes the program to abort.

Definition at line 182 of file CommandProxy.cpp.

CommandProxy::CommandIDRegistry & CommandProxy::getCommandIDRegistry (  )  [static, private]

Definition at line 517 of file CommandProxy.cpp.

size_t CommandProxy::getCommandObjSize ( const CommandIDType id  )  const

Definition at line 561 of file CommandProxy.cpp.

CommandReaderInterface * CommandProxy::getCommandReader ( const std::string &  role  )  const

Definition at line 208 of file CommandProxy.cpp.

CommandProxy::CommandReaderRegistry & CommandProxy::getCommandReaderRegistry (  )  [static, private]

Definition at line 545 of file CommandProxy.cpp.

const CommandTypeSpecifierInterface * CommandProxy::getCommandTypeSpecifier ( CommandIDType  id  )  const [private]

Definition at line 501 of file CommandProxy.cpp.

CommandProxy::CopyCommandInterfaceRegistry & CommandProxy::getCopyCommandRegistry (  )  [static, private]

Definition at line 538 of file CommandProxy.cpp.

const CommandTypeSpecifierInterface * CommandProxy::getNext ( const CommandPool commandPool,
const CommandTypeSpecifierInterface questioner 
) const [private]

Definition at line 282 of file CommandProxy.cpp.

void CommandProxy::partialCopy ( const CommandTypeSpecifierInterface initiator,
CommandPool dst,
const CommandPool src 
) const

Copy only those Commands that have been activated upto the time where the initiator activated its Command.

This method has to be used, when bridging to avoid an invalid reactivation of Commands that have been activated already in an earlier run through a protocol stack. Suppose FunctionalUnit A receives an incoming PDU and wants to inject a copy of the PDU back into itself. If FunctionalUnit A would make a full copy of the CommandPool, a FunctionalUnit B that is below A would have seen the PDU before and the Command of FunctionalUnit B would have been already activated. When the PDU reaches FunctionalUnit B the second time, there is no way (and should not be) for FunctionalUnit B to tell if it has activated the Command already. Since activation of an already activated Command is considered a defect, an exception is raised.

Definition at line 478 of file CommandProxy.cpp.

std::string wns::ldk::CommandProxy::printCommandIDRegistryKeys (  )  [inline]

Definition at line 363 of file CommandProxy.hpp.

void CommandProxy::removeFunctionalUnit ( const std::string &  commandName  ) 

De-register a Functional Unit from the CommandProxy. The FU can't operate on the CommandPool after this.

Definition at line 149 of file CommandProxy.cpp.


Friends And Related Function Documentation

friend class CommandPool [friend]

Definition at line 78 of file CommandProxy.hpp.

friend class CommandReaderInterface [friend]

Definition at line 77 of file CommandProxy.hpp.


Member Data Documentation

Definition at line 400 of file CommandProxy.hpp.

Definition at line 398 of file CommandProxy.hpp.

Definition at line 110 of file CommandProxy.hpp.

Definition at line 402 of file CommandProxy.hpp.


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

Generated on Sat May 26 03:32:54 2012 for openWNS by  doxygen 1.5.5