HydraNode Class Reference

#include <hydranode.h>

Inheritance diagram for HydraNode:

Inheritance graph
[legend]
Collaboration diagram for HydraNode:

Collaboration graph
[legend]
List of all members.

Detailed Description

Main application class.

Definition at line 109 of file hydranode.h.


Public Member Functions

 DECLARE_EVENT_TABLE (HydraNode *, HNEvent)
void init (int argc, char **argv)
 Initialize HydraNode core.
int run (int argc, char **argv)
 Runs the hydranode core, performing initialization, mainloop until exit command is received, and then cleanup.
int cleanup ()
 Called on shutdown, this method performs all cleanup and saving all settings.
int mainLoop ()
 Main event loop.
void doLoop ()
 Perform a single event loop.
boost::filesystem::path getConfigDir ()
 Accessor, retrieves configuration directory.
void exit ()
 Exit the application.
uint32_t getAppVer () const
 Retrieve the application version.
std::string getAppVerLong () const
 Get a human-readable application version string.
bool isRunning () const
 Check if the application is running.

Static Public Member Functions

static HydraNodeinstance ()
 Returns the single instance of this Singleton.

Private Member Functions

boost::filesystem::path checkCreateDir (boost::filesystem::path dir, const std::string &alt)
 Check for directories existance, and create it if neccesery.
void onEvent (HydraNode *hn, HNEvent evt)
 Event handler for our own events, used for some regular tasks.
Various initialization functions
void initConfig ()
void initLog ()
void initSockets ()
void initModules ()
void initFiles ()
Singleton
 HydraNode ()
 Forbidden.
 HydraNode (const HydraNode &)
 Forbidden.
HydraNodeoperator= (HydraNode &)
 Forbidden.
 ~HydraNode ()
 Forbidden.

Private Attributes

bool m_running
 Keeps track if we are running.
boost::filesystem::path m_confDir
 Global configuration directory.
uint32_t m_buildDate
 Application binary build/modification date.

Constructor & Destructor Documentation

HydraNode::HydraNode  )  [private]
 

Forbidden.

Note: Don't do initialization here. That's what run() member function is for.

Definition at line 49 of file hydranode.cpp.

HydraNode::HydraNode const HydraNode  )  [private]
 

Forbidden.

HydraNode::~HydraNode  )  [private]
 

Forbidden.

Definition at line 50 of file hydranode.cpp.


Member Function Documentation

boost::filesystem::path HydraNode::checkCreateDir boost::filesystem::path  dir,
const std::string &  alt
[private]
 

Check for directories existance, and create it if neccesery.

Parameters:
dir Path to check/create.
alt Alternative directory name to be used if smth fails
Returns:
The directory checked/created.
If something goes terribly wrong in the directory checking/creation, this method attempts to use a subdirectory from current working directory. If that also fails, it will throw an exception. The return value indicates the actual directory after all these checks, and may differ from the original passed path.

Definition at line 128 of file hydranode.cpp.

References logError(), and s_argv.

Referenced by initConfig().

Here is the call graph for this function:

int HydraNode::cleanup  ) 
 

Called on shutdown, this method performs all cleanup and saving all settings.

Returns:
0 on clean shutdown, nonzero error code otherwise.

Definition at line 104 of file hydranode.cpp.

References SchedBase::exit(), getConfigDir(), MetaDb::instance(), FilesList::instance(), Prefs::instance(), SchedBase::instance(), ModManager::instance(), logMsg(), ModManager::onExit(), Config::save(), and FilesList::savePartFiles().

Referenced by run().

Here is the call graph for this function:

HydraNode::DECLARE_EVENT_TABLE HydraNode ,
HNEvent 
 

void HydraNode::doLoop  ) 
 

Perform a single event loop.

Definition at line 314 of file hydranode.cpp.

References EventMain::handlePending(), EventMain::instance(), and SocketWatcher::poll().

Referenced by mainLoop().

Here is the call graph for this function:

void HydraNode::exit  )  [inline]
 

Exit the application.

Definition at line 167 of file hydranode.h.

uint32_t HydraNode::getAppVer  )  const
 

Retrieve the application version.

The return value bytes are set as follows: [null] [major] [minor] [patch] Thus version 2.5.3 would return a 4-byte value with the following content: 0253

Definition at line 331 of file hydranode.cpp.

References APPVER_MAJOR, APPVER_MINOR, and APPVER_PATCH.

std::string HydraNode::getAppVerLong  )  const
 

Get a human-readable application version string.

The returned string is something like this: "HydraNode v0.4.6"

Definition at line 335 of file hydranode.cpp.

Referenced by initLog().

boost::filesystem::path HydraNode::getConfigDir  )  [inline]
 

Accessor, retrieves configuration directory.

Returns:
Current configuration directory

Definition at line 160 of file hydranode.h.

Referenced by cleanup(), initFiles(), initLog(), and onEvent().

void HydraNode::init int  argc,
char **  argv
 

Initialize HydraNode core.

Parameters:
argc Number of arguments
argv Arguments

Definition at line 58 of file hydranode.cpp.

References Log::addPreStr(), Utils::getModDate(), initConfig(), initFiles(), initLog(), initModules(), initSockets(), Log::instance(), logMsg(), m_buildDate, m_running, onEvent(), Log::remPreStr(), s_argc, and s_argv.

Referenced by run().

Here is the call graph for this function:

void HydraNode::initConfig  )  [private]
 

Definition at line 157 of file hydranode.cpp.

References checkCreateDir(), Prefs::instance(), Config::load(), logMsg(), m_confDir, s_argv, and Config::write().

Referenced by init().

Here is the call graph for this function:

void HydraNode::initFiles  )  [private]
 

Definition at line 243 of file hydranode.cpp.

References FilesList::addSharedDir(), FilesList::addTempDir(), EVT_SAVE_MDB, getConfigDir(), Prefs::instance(), MetaDb::instance(), FilesList::instance(), MetaDb::load(), logError(), logMsg(), METADB_SAVETIME, Config::read(), and Config::setPath().

Referenced by init().

Here is the call graph for this function:

void HydraNode::initLog  )  [private]
 

Definition at line 208 of file hydranode.cpp.

References Log::addLogFile(), getAppVerLong(), getConfigDir(), Log::instance(), logMsg(), and m_buildDate.

Referenced by init().

Here is the call graph for this function:

void HydraNode::initModules  )  [private]
 

Definition at line 319 of file hydranode.cpp.

References Prefs::instance(), ModManager::instance(), ModManager::loadModule(), ModManager::onInit(), Config::read(), and Config::write().

Referenced by init().

Here is the call graph for this function:

void HydraNode::initSockets  )  [private]
 

Definition at line 234 of file hydranode.cpp.

References SchedBase::instance().

Referenced by init().

Here is the call graph for this function:

HydraNode & HydraNode::instance  )  [static]
 

Returns the single instance of this Singleton.

Definition at line 52 of file hydranode.cpp.

Referenced by main().

bool HydraNode::isRunning  )  const [inline]
 

Check if the application is running.

This indicates whether the application is inside main loop, e.g. not starting up or shutting down.

Definition at line 189 of file hydranode.h.

int HydraNode::mainLoop  ) 
 

Main event loop.

This method enters HydraNode main loop, calling doLoop() until m_running is true, and then exits the application.

Returns:
0 on clean exit, nonzero error code otherwise.

Definition at line 302 of file hydranode.cpp.

References doLoop(), EVT_EXIT, EventMain::handlePending(), EventMain::initialize(), EventMain::instance(), and m_running.

Referenced by run().

Here is the call graph for this function:

void HydraNode::onEvent HydraNode hn,
HNEvent  evt
[private]
 

Event handler for our own events, used for some regular tasks.

Definition at line 339 of file hydranode.cpp.

References EVT_SAVE_MDB, getConfigDir(), MetaDb::instance(), FilesList::instance(), Prefs::instance(), logMsg(), METADB_SAVETIME, Config::save(), and FilesList::savePartFiles().

Referenced by init().

Here is the call graph for this function:

HydraNode& HydraNode::operator= HydraNode  )  [private]
 

Forbidden.

int HydraNode::run int  argc,
char **  argv
 

Runs the hydranode core, performing initialization, mainloop until exit command is received, and then cleanup.

Parameters:
argc Number of arguments
argv Arguments
Returns:
0 on clean shutdown, nonzero error code otherwise.

Definition at line 98 of file hydranode.cpp.

References cleanup(), init(), and mainLoop().

Referenced by main().

Here is the call graph for this function:


Member Data Documentation

uint32_t HydraNode::m_buildDate [private]
 

Application binary build/modification date.

Definition at line 224 of file hydranode.h.

Referenced by init(), and initLog().

boost::filesystem::path HydraNode::m_confDir [private]
 

Global configuration directory.

Definition at line 221 of file hydranode.h.

Referenced by initConfig().

bool HydraNode::m_running [private]
 

Keeps track if we are running.

Definition at line 218 of file hydranode.h.

Referenced by init(), and mainLoop().


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