Sirikata
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
Sirikata::Command::Commander Class Reference

Commanders accept external commands (e.g. More...

#include <Commander.hpp>

Inheritance diagram for Sirikata::Command::Commander:
Collaboration diagram for Sirikata::Command::Commander:

List of all members.

Public Member Functions

 Commander ()
virtual ~Commander ()
virtual void registerCommand (const CommandKey &name, CommandHandler handler)
 Register a handler for a command.
virtual void unregisterCommand (const CommandKey &name)
 Unregister a handler for the command.
virtual void result (CommandID id, const Result &result)=0
 Return a result from a CommandHandler.

Protected Types

typedef boost::recursive_mutex Mutex
typedef boost::lock_guard< MutexLock
typedef
std::tr1::unordered_map
< CommandKey, CommandHandler
HandlerMap

Protected Member Functions

CommandHandler getHandler (const CommandKey &name)
 Utility for implementations which looks up the appropriate handler for the command.
void commandListCommands (const Command &cmd, Commander *cmdr, CommandID cmdid)

Protected Attributes

Mutex mMutex
HandlerMap mHandlers

Detailed Description

Commanders accept external commands (e.g.

over the network) and dispatch them to the appropriate handlers. This provides the basic interface and implementation for handler registration, dispatch, and result handling. Implementations are responsible for generating Commands, invoking dispatch(), and sending out replies.


Member Typedef Documentation

typedef std::tr1::unordered_map<CommandKey, CommandHandler> Sirikata::Command::Commander::HandlerMap [protected]
typedef boost::lock_guard<Mutex> Sirikata::Command::Commander::Lock [protected]
typedef boost::recursive_mutex Sirikata::Command::Commander::Mutex [protected]

Constructor & Destructor Documentation

Sirikata::Command::Commander::Commander ( )
Sirikata::Command::Commander::~Commander ( ) [virtual]

Member Function Documentation

void Sirikata::Command::Commander::commandListCommands ( const Command cmd,
Commander cmdr,
CommandID  cmdid 
) [protected]
CommandHandler Sirikata::Command::Commander::getHandler ( const CommandKey name) [protected]

Utility for implementations which looks up the appropriate handler for the command.

References mHandlers, mMutex, and name().

Referenced by Sirikata::Command::HttpCommander::onHttpRequest().

void Sirikata::Command::Commander::registerCommand ( const CommandKey name,
CommandHandler  handler 
) [virtual]

Register a handler for a command.

Throws DuplicateHandlerException if the handler is already registered.

Parameters:
namethe name of the command
handlerthe CommandHandler to process this
Note:
Your handler is responsible for ensuring it executes on the correct thread. Commanders may invoke them from any thread, especially since they may have separate networking threads.

References mHandlers, mMutex, and name().

Referenced by Sirikata::AggregateManager::AggregateManager(), Commander(), Sirikata::LocationService::LocationService(), Sirikata::ObjectHost::ObjectHost(), Sirikata::Graphics::PriorityDownloadPlanner::PriorityDownloadPlanner(), Sirikata::Transfer::TransferMediator::registerContext(), Sirikata::Server::Server(), and Sirikata::Context::setCommander().

virtual void Sirikata::Command::Commander::result ( CommandID  id,
const Result result 
) [pure virtual]

Return a result from a CommandHandler.

This will trigger the process of returning the result to the requestor.

Implemented in Sirikata::Command::HttpCommander.

Referenced by Sirikata::ObjectHost::commandCreateObject(), Sirikata::ObjectHost::commandDestroyObject(), Sirikata::PintoManager::commandForceRebuild(), Sirikata::ManualPintoManager::commandForceRebuild(), Sirikata::LibproxProximity::commandForceRebuild(), Sirikata::LibproxManualProximity::commandForceRebuild(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandForceRebuild(), Sirikata::OH::Manual::ObjectQueryHandler::commandForceRebuild(), Sirikata::Graphics::PriorityDownloadPlanner::commandGetData(), Sirikata::Graphics::PriorityDownloadPlanner::commandGetStats(), commandListCommands(), Sirikata::PintoManager::commandListHandlers(), Sirikata::ManualPintoManager::commandListHandlers(), Sirikata::LibproxProximity::commandListHandlers(), Sirikata::LibproxManualProximity::commandListHandlers(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandListHandlers(), Sirikata::OH::Manual::ManualObjectQueryProcessor::commandListHandlers(), Sirikata::PintoManager::commandListNodes(), Sirikata::ManualPintoManager::commandListNodes(), Sirikata::LibproxProximity::commandListNodes(), Sirikata::LibproxManualProximity::commandListNodes(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandListNodes(), Sirikata::OH::Manual::ObjectQueryHandler::commandListNodes(), Sirikata::ObjectHost::commandListObjects(), Sirikata::PintoManager::commandListQueriers(), Sirikata::ManualPintoManager::commandListQueriers(), Sirikata::LibproxProximity::commandListQueriers(), Sirikata::LibproxManualProximity::commandListQueriers(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandListQueriers(), Sirikata::OH::Manual::ManualObjectQueryProcessor::commandListQueriers(), Sirikata::Transfer::TransferMediator::commandListRequests(), Sirikata::StandardLocationService::commandObjectProperties(), Sirikata::BulletPhysicsService::commandObjectProperties(), Sirikata::Server::commandObjectsCount(), Sirikata::Server::commandObjectsDisconnect(), Sirikata::Server::commandObjectsList(), Sirikata::HostedObject::commandPresences(), Sirikata::PintoManager::commandProperties(), Sirikata::ManualPintoManager::commandProperties(), Sirikata::StandardLocationService::commandProperties(), Sirikata::LibproxProximity::commandProperties(), Sirikata::LibproxManualProximity::commandProperties(), Sirikata::BulletPhysicsService::commandProperties(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandProperties(), Sirikata::OH::Manual::ManualObjectQueryProcessor::commandProperties(), Sirikata::Network::IOService::commandReportAllStats(), Sirikata::Network::IOService::commandReportStats(), Sirikata::PintoManager::commandStats(), Sirikata::ManualPintoManager::commandStats(), Sirikata::AggregateManager::commandStats(), Sirikata::LibproxProximityBase::commandStats(), Sirikata::OH::Simple::SimpleObjectQueryProcessor::commandStats(), Sirikata::OH::Manual::ManualObjectQueryProcessor::commandStats(), Sirikata::ObjectHost::getCommandObject(), and Sirikata::OH::Manual::ManualObjectQueryProcessor::lookupCommandHandler().

void Sirikata::Command::Commander::unregisterCommand ( const CommandKey name) [virtual]

Unregister a handler for the command.

Parameters:
namethe name of the command

References mHandlers, and mMutex.

Referenced by Sirikata::Context::setCommander().


Member Data Documentation


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