adchpp::SocketManager Class Reference

#include <SocketManager.h>

Inheritance diagram for adchpp::SocketManager:
Inheritance graph
[legend]
Collaboration diagram for adchpp::SocketManager:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::function< void()> Callback
typedef std::function< void(const
ManagedSocketPtr &)> 
IncomingHandler

Public Member Functions

ADCHPP_DLL void addJob (const std::string &time, const Callback &callback)
 execute a function after the specified amount of time
ADCHPP_DLL void addJob (const long msec, const Callback &callback)
 execute a function after the specified amount of time
ADCHPP_DLL void addJob (const Callback &callback) throw ()
 execute a function asynchronously
ADCHPP_DLL Callback addTimedJob (const std::string &time, const Callback &callback)
 execute a function at regular intervals
ADCHPP_DLL Callback addTimedJob (const long msec, const Callback &callback)
 execute a function at regular intervals
ADCHPP_DLL void join () throw ()
void setIncomingHandler (const IncomingHandler &handler)
void setServers (const ServerInfoList &servers_)
void shutdown ()
ADCHPP_DLL void start () throw (ThreadException)
void startup () throw (ThreadException)

Static Public Member Functions

static void deleteInstance ()
static SocketManagergetInstance ()
static void newInstance ()

Public Attributes

std::map< std::string, int > errors

Static Protected Member Functions

static void * starter (void *p)

Protected Attributes

pthread_t t

Private Types

typedef shared_ptr
< boost::asio::deadline_timer > 
timer_ptr

Private Member Functions

void addJob (const boost::asio::deadline_timer::duration_type &duration, const Callback &callback)
Callback addTimedJob (const boost::asio::deadline_timer::duration_type &duration, const Callback &callback)
void cancelTimer (timer_ptr timer, Callback *callback)
void closeFactories ()
void handleWait (timer_ptr timer, const boost::asio::deadline_timer::duration_type &duration, const boost::system::error_code &error, Callback *callback)
void onLoad (const SimpleXML &xml) throw ()
virtual int run ()
void setTimer (timer_ptr timer, const boost::asio::deadline_timer::duration_type &duration, Callback *callback)
 SocketManager ()
virtual ~SocketManager ()

Private Attributes

std::vector< SocketFactoryPtrfactories
IncomingHandler incomingHandler
boost::asio::io_service io
ServerInfoList servers
std::unique_ptr
< boost::asio::io_service::work > 
work

Static Private Attributes

static const std::string className = "SocketManager"
static ADCHPP_DLL SocketManagerinstance = 0

Friends

class ManagedSocket
class Singleton< SocketManager >
class SocketFactory

Detailed Description

Definition at line 33 of file SocketManager.h.


Member Typedef Documentation

typedef std::function<void()> adchpp::SocketManager::Callback

Definition at line 35 of file SocketManager.h.

typedef std::function<void (const ManagedSocketPtr&)> adchpp::SocketManager::IncomingHandler

Definition at line 62 of file SocketManager.h.

typedef shared_ptr<boost::asio::deadline_timer> adchpp::SocketManager::timer_ptr [private]

Definition at line 88 of file SocketManager.h.


Constructor & Destructor Documentation

adchpp::SocketManager::SocketManager (  )  [private]

Definition at line 41 of file SocketManager.cpp.

adchpp::SocketManager::~SocketManager (  )  [private, virtual]

Definition at line 45 of file SocketManager.cpp.


Member Function Documentation

void adchpp::SocketManager::addJob ( const boost::asio::deadline_timer::duration_type &  duration,
const Callback callback 
) [private]
void adchpp::SocketManager::addJob ( const std::string &  time,
const Callback callback 
)

execute a function after the specified amount of time

Parameters:
time a string that obeys to the "[-]h[h][:mm][:ss][.fff]" format

Definition at line 255 of file SocketManager.cpp.

References addJob().

Here is the call graph for this function:

void adchpp::SocketManager::addJob ( const long  msec,
const Callback callback 
)

execute a function after the specified amount of time

Parameters:
msec milliseconds

Definition at line 251 of file SocketManager.cpp.

References addJob().

Here is the call graph for this function:

void adchpp::SocketManager::addJob ( const Callback callback  )  throw ()

execute a function asynchronously

Definition at line 247 of file SocketManager.cpp.

Referenced by addJob(), adchpp::ManagedSocket::disconnect(), adchpp::Bot::disconnect(), and shutdown().

Here is the caller graph for this function:

Callback adchpp::SocketManager::addTimedJob ( const boost::asio::deadline_timer::duration_type &  duration,
const Callback callback 
) [private]
SocketManager::Callback adchpp::SocketManager::addTimedJob ( const std::string &  time,
const Callback callback 
)

execute a function at regular intervals

Parameters:
time a string that obeys to the "[-]h[h][:mm][:ss][.fff]" format
Returns:
function one must call to cancel the timer (its callback will still be executed)

Definition at line 263 of file SocketManager.cpp.

References addTimedJob().

Here is the call graph for this function:

SocketManager::Callback adchpp::SocketManager::addTimedJob ( const long  msec,
const Callback callback 
)

execute a function at regular intervals

Parameters:
msec milliseconds
Returns:
function one must call to cancel the timer (its callback will still be executed)

Definition at line 259 of file SocketManager.cpp.

Referenced by addTimedJob().

Here is the caller graph for this function:

void adchpp::SocketManager::cancelTimer ( timer_ptr  timer,
Callback callback 
) [private]

Definition at line 301 of file SocketManager.cpp.

void adchpp::SocketManager::closeFactories (  )  [private]

Definition at line 240 of file SocketManager.cpp.

References factories.

Referenced by shutdown().

Here is the caller graph for this function:

static void adchpp::Singleton< SocketManager >::deleteInstance (  )  [inline, static, inherited]

Definition at line 49 of file Singleton.h.

static SocketManager * adchpp::Singleton< SocketManager >::getInstance (  )  [inline, static, inherited]

Definition at line 37 of file Singleton.h.

Referenced by adchpp::ManagedSocket::disconnect(), adchpp::Bot::disconnect(), adchpp::ManagedSocket::failSocket(), and adchpp::SocketFactory::prepareAccept().

Here is the caller graph for this function:

void adchpp::SocketManager::handleWait ( timer_ptr  timer,
const boost::asio::deadline_timer::duration_type &  duration,
const boost::system::error_code &  error,
Callback callback 
) [private]
void adchpp::Thread::join (  )  throw () [inherited]

Definition at line 68 of file Thread.cpp.

References adchpp::Thread::t.

Referenced by shutdown().

Here is the caller graph for this function:

static void adchpp::Singleton< SocketManager >::newInstance (  )  [inline, static, inherited]

Definition at line 42 of file Singleton.h.

void adchpp::SocketManager::onLoad ( const SimpleXML xml  )  throw () [private]

Definition at line 322 of file SocketManager.cpp.

int adchpp::SocketManager::run (  )  [private, virtual]

Implements adchpp::Thread.

Definition at line 218 of file SocketManager.cpp.

References className, factories, incomingHandler, io, LOG, servers, and adchpp::Util::toString().

Here is the call graph for this function:

void adchpp::SocketManager::setIncomingHandler ( const IncomingHandler handler  )  [inline]

Definition at line 63 of file SocketManager.h.

References incomingHandler.

void adchpp::SocketManager::setServers ( const ServerInfoList servers_  )  [inline]

Definition at line 60 of file SocketManager.h.

References servers.

void adchpp::SocketManager::setTimer ( timer_ptr  timer,
const boost::asio::deadline_timer::duration_type &  duration,
Callback callback 
) [private]
void adchpp::SocketManager::shutdown (  ) 

Definition at line 315 of file SocketManager.cpp.

References addJob(), closeFactories(), io, adchpp::Thread::join(), and work.

Here is the call graph for this function:

void adchpp::Thread::start (  )  throw (ThreadException) [inherited]

Definition at line 52 of file Thread.cpp.

References _T, adchpp::Thread::starter(), adchpp::Thread::t, and adchpp::Util::translateError().

Referenced by startup().

Here is the call graph for this function:

Here is the caller graph for this function:

static void* adchpp::Thread::starter ( void *  p  )  [inline, static, protected, inherited]

Definition at line 96 of file Thread.h.

References adchpp::Thread::run(), and adchpp::Thread::t.

Referenced by adchpp::Thread::start().

Here is the call graph for this function:

Here is the caller graph for this function:

void adchpp::SocketManager::startup (  )  throw (ThreadException)

Definition at line 310 of file SocketManager.cpp.

References io, adchpp::Thread::start(), and work.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class ManagedSocket [friend]

Definition at line 68 of file SocketManager.h.

friend class Singleton< SocketManager > [friend]

Definition at line 85 of file SocketManager.h.

friend class SocketFactory [friend]

Definition at line 69 of file SocketManager.h.


Member Data Documentation

const string adchpp::SocketManager::className = "SocketManager" [static, private]

Definition at line 83 of file SocketManager.h.

Referenced by run().

std::map<std::string, int> adchpp::SocketManager::errors

Definition at line 65 of file SocketManager.h.

Referenced by adchpp::ManagedSocket::failSocket().

Definition at line 79 of file SocketManager.h.

Referenced by closeFactories(), and run().

Definition at line 81 of file SocketManager.h.

Referenced by run(), and setIncomingHandler().

Definition at line 86 of file SocketManager.h.

boost::asio::io_service adchpp::SocketManager::io [private]

Definition at line 75 of file SocketManager.h.

Referenced by run(), shutdown(), and startup().

Definition at line 78 of file SocketManager.h.

Referenced by run(), and setServers().

pthread_t adchpp::Thread::t [protected, inherited]

Definition at line 95 of file Thread.h.

Referenced by adchpp::Thread::join(), adchpp::Thread::start(), and adchpp::Thread::starter().

std::unique_ptr<boost::asio::io_service::work> adchpp::SocketManager::work [private]

Definition at line 76 of file SocketManager.h.

Referenced by shutdown(), and startup().

Generated on Sat Nov 27 23:38:54 2010 for adchpp by  doxygen 1.6.3