MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
mds::mod::CConsole Class Reference

Class encapsulating a simple console application. More...

#include <mdsConsole.h>

Inheritance diagram for mds::mod::CConsole:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { CLASS_OBJECT }
 Templates that require members of the CObject class can use this enum to check the existence. More...
enum  { HEAP_OBJECT = 0x70616568 }
 Signature used to recognize objects on the heap. More...

Public Member Functions

void allowArguments (const std::string &sArgs)
 Additinal command line arguments should be specified.
 CConsole (const std::string &sDescription)
 Default constructor.
void exit ()
 Exits the application.
CArgvgetArguments ()
 Returns pointer to the parsed command line arguments.
const std::string & getDescription () const
 Returns the application description.
const std::string & getFilename () const
 Returns real name of the executed binary application.
int getReferencesCount () const
 Returns the number of references.
virtual bool init (int argc, char *argv[])
 Initializes console application and parses a given command line.
bool isActive ()
 Returns true whenever the processing thread is running.
bool isOnHeap () const
 Returns true if the object is allocated on the heap.
virtual bool main ()=0
 Virtual method repeatedly called by the processing thread.
 MDS_SHAREDPTR (CConsole)
 Smart pointer type.
virtual void printFullUsage ()
 Writes full help to the cerr stream.
virtual void printUsage ()
 Writes simple usage to the cerr stream.
bool run ()
 Executes processing thread and console I/O.
virtual void shutdown ()=0
 Called on console shutdown.
virtual bool startup ()=0
 Virtual method called on console startup.
virtual void writeExtendedUsage (std::ostream &Stream)=0
 Called on writing a full usage statement.
virtual ~CConsole ()
 Virtual destructor.

Static Public Member Functions

static void * operator new (std::size_t Size)
 Allocates a new object on the heap.

Protected Member Functions

void addReference () const
 Increase the reference counter.
bool delReference () const
 Decrease the reference counter.

Static Protected Member Functions

static int threadRoutine (mds::sys::CThread *pThread)
 The main thread routine.

Protected Attributes

CArgv m_Arguments
 Parsed command line arguments.
mds::sys::CExitHandler m_ExitHandler
 Exit handler.
int m_iHeapObject
 Flag initialized if the object is on the heap.
int m_iReferences
 The number of references to the object.
std::string m_sAllowedArguments
 Allowed command line arguments.
std::string m_sDescription
 Application description.
std::string m_sFilename
 Application filename.
mds::sys::CThread m_Thread
 Processing thread.

Detailed Description

Class encapsulating a simple console application.


Member Enumeration Documentation

anonymous enum [inherited]

Templates that require members of the CObject class can use this enum to check the existence.

Enumerator:
CLASS_OBJECT 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

mds::mod::CConsole::CConsole ( const std::string &  sDescription)

Default constructor.

Virtual destructor.


Member Function Documentation

void mds::base::CObject::addReference ( ) const [protected, inherited]

Increase the reference counter.

void mds::mod::CConsole::allowArguments ( const std::string &  sArgs)

Additinal command line arguments should be specified.

  • Individual arguments are separated by colon.
bool mds::base::CObject::delReference ( ) const [protected, inherited]

Decrease the reference counter.

  • Returns true if the decremented number of references is lower or equal to zero and object must be deleted.

Exits the application.

Returns pointer to the parsed command line arguments.

const std::string& mds::mod::CConsole::getDescription ( ) const

Returns the application description.

const std::string& mds::mod::CConsole::getFilename ( ) const

Returns real name of the executed binary application.

Returns the number of references.

bool mds::mod::CConsole::init ( int  argc,
char *  argv[] 
) [virtual]

Initializes console application and parses a given command line.

  • Returns false on failure.

Reimplemented in mds::mod::CModule, and mds::mod::CView.

Returns true whenever the processing thread is running.

bool mds::base::CObject::isOnHeap ( ) const [inherited]

Returns true if the object is allocated on the heap.

virtual bool mds::mod::CConsole::main ( ) [pure virtual]

Virtual method repeatedly called by the processing thread.

  • Expected to be overriden in concrete module!
  • When you need to stop the execution just return false.

Implemented in mds::mod::CModule, and mds::mod::CView.

Smart pointer type.

  • Declares type tSmartPtr.
static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

Writes full help to the cerr stream.

Reimplemented in mds::mod::CModule, and mds::mod::CView.

void mds::mod::CConsole::printUsage ( ) [virtual]

Writes simple usage to the cerr stream.

Reimplemented in mds::mod::CModule, and mds::mod::CView.

Executes processing thread and console I/O.

  • Returns false if the module cannot start.
virtual void mds::mod::CConsole::shutdown ( ) [pure virtual]

Called on console shutdown.

  • Expected to be overriden in concrete module!

Implemented in mds::mod::CModule, and mds::mod::CView.

virtual bool mds::mod::CConsole::startup ( ) [pure virtual]

Virtual method called on console startup.

  • Expected to be overriden in concrete module!
  • Returns false on failure.

Implemented in mds::mod::CModule, and mds::mod::CView.

static int mds::mod::CConsole::threadRoutine ( mds::sys::CThread pThread) [static, protected]

The main thread routine.

virtual void mds::mod::CConsole::writeExtendedUsage ( std::ostream &  Stream) [pure virtual]

Called on writing a full usage statement.

  • Expected to be overriden in concrete module!

Implemented in mds::mod::CModule, and mds::mod::CView.


Member Data Documentation

Parsed command line arguments.

Exit handler.

int mds::base::CObject::m_iHeapObject [mutable, protected, inherited]

Flag initialized if the object is on the heap.

int mds::base::CObject::m_iReferences [mutable, protected, inherited]

The number of references to the object.

  • Zero if there is no reference.
std::string mds::mod::CConsole::m_sAllowedArguments [protected]

Allowed command line arguments.

std::string mds::mod::CConsole::m_sDescription [protected]

Application description.

std::string mds::mod::CConsole::m_sFilename [protected]

Application filename.

Processing thread.


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