Base::ConsoleSingleton Class Reference

The console class This class manage all the stdio stuff. More...

#include <Console.h>

List of all members.

Public Types

enum  ConsoleMode { Verbose = 1 }
 

enumaration for the console modes

More...
enum  FreeCAD_ConsoleMsgType { MsgType_Txt = 1, MsgType_Log = 2, MsgType_Wrn = 4, MsgType_Err = 8 }

Public Member Functions

void AttachObserver (ConsoleObserver *pcObserver)
 Attaches an Observer to FCConsole.
void DetachObserver (ConsoleObserver *pcObserver)
 Detaches an Observer from FCConsole.
virtual void Error (const char *pMsg,...)
 Prints a error Message.
ConsoleObserverGet (const char *Name)
virtual void Log (const char *pMsg,...)
 Prints a log Message.
virtual void Message (const char *pMsg,...)
 Prints a Message.
ConsoleMsgFlags SetEnabledMsgType (const char *sObs, ConsoleMsgFlags type, bool b)
 Enables or disables message types of a cetain console observer.
void SetMode (ConsoleMode m)
 Change mode.
const char * Time (void)
 Delivers a time/date string.
void UnsetMode (ConsoleMode m)
 Change mode.
virtual void Warning (const char *pMsg,...)
 Prints a warning Message.

Static Public Member Functions

static ConsoleSingletonInstance (void)
 singleton

Static Public Attributes

static PyMethodDef Methods []

Protected Member Functions

 ConsoleSingleton (void)
virtual ~ConsoleSingleton ()

Static Protected Member Functions

static PyObjectsPyError (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsPyGetStatus (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsPyLog (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsPyMessage (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsPySetStatus (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsPyWarning (PyObject *self, PyObject *args, PyObject *kwd)

Protected Attributes

bool _bVerbose

Detailed Description

The console class This class manage all the stdio stuff.

This includes Messages, Warnings, Log entries and Errors. The incomming Messages are distributed with the FCConsoleObserver. The FCConsole class itself makes no IO, it's more like a manager.

ConsoleSingleton is a singleton! That means you can access the only instance of the class from every where in c++ by simply using:
  #include <Base/Console.h>
  Base::Console().Log("Stage: %d",i);
ConsoleSingleton is abel to switch between several modes to, e.g. switch the logging on or off, or treat Warnings as Errors, and so on...
See also:
ConsoleObserver

Definition at line 105 of file Console.h.


Member Enumeration Documentation

enumaration for the console modes

Enumerator:
Verbose 

Definition at line 127 of file Console.h.

Enumerator:
MsgType_Txt 
MsgType_Log 
MsgType_Wrn 
MsgType_Err 

Definition at line 131 of file Console.h.


Constructor & Destructor Documentation

ConsoleSingleton::ConsoleSingleton ( void   )  [protected]

Definition at line 53 of file Console.cpp.

Referenced by Instance().

ConsoleSingleton::~ConsoleSingleton (  )  [protected, virtual]

Definition at line 59 of file Console.cpp.


Member Function Documentation

void ConsoleSingleton::AttachObserver ( ConsoleObserver pcObserver  ) 

Attaches an Observer to FCConsole.

Attaches an Observer to Console Use this method to attach a ConsoleObserver derived class to the Console.

After the observer is attached all messages will also forwardet to it.

See also:
ConsoleObserver

Definition at line 265 of file Console.cpp.

void ConsoleSingleton::DetachObserver ( ConsoleObserver pcObserver  ) 

Detaches an Observer from FCConsole.

Detaches an Observer from Console Use this method to detach a ConsoleObserver derived class.

After detaching you can destruct the Observer or reinsert it later.

See also:
ConsoleObserver

Definition at line 278 of file Console.cpp.

Referenced by App::Application::destructObserver().

void ConsoleSingleton::Error ( const char *  pMsg,
  ... 
) [virtual]

Prints a error Message.

Prints a Message This method issues an Error which makes some execution imposible.

Errors are used to get the users attantion. That means in the case FreeCAD running with GUI a Error Message Box is poping up. In console mode a colored message comes out! So dont use this careless. For information purpose the Log or Message method is more aprobiated.

You can use a printf like interface like:
  Console().Error("Somthing realy bad in %s happend\n",str);
See also:
Message
Warning
Log

Definition at line 198 of file Console.cpp.

References format, and format_len.

Referenced by Base::VectorPy::_getattr(), Base::RotationPy::_getattr(), Base::PlacementPy::_getattr(), Base::PersistencePy::_getattr(), Base::MatrixPy::_getattr(), Base::BoundBoxPy::_getattr(), Base::BaseClassPy::_getattr(), Base::VectorPy::_setattr(), Base::RotationPy::_setattr(), Base::PlacementPy::_setattr(), Base::PersistencePy::_setattr(), Base::MatrixPy::_setattr(), Base::BoundBoxPy::_setattr(), Base::BaseClassPy::_setattr(), App::Application::processCmdLineFiles(), Base::XMLReader::readFiles(), Base::Exception::ReportException(), App::PropertyContainer::Restore(), App::PropertyContainer::Save(), sPyError(), Base::VectorPy::staticCallback_add(), Base::BoundBoxPy::staticCallback_add(), Base::PlacementPy::staticCallback_copy(), Base::VectorPy::staticCallback_cross(), Base::MatrixPy::staticCallback_determinant(), Base::VectorPy::staticCallback_distanceToLine(), Base::VectorPy::staticCallback_distanceToPlane(), Base::VectorPy::staticCallback_dot(), Base::BoundBoxPy::staticCallback_enlarge(), Base::BaseClassPy::staticCallback_getAllDerivedFrom(), Base::VectorPy::staticCallback_getAngle(), Base::BoundBoxPy::staticCallback_getIntersectionPoint(), Base::PlacementPy::staticCallback_inverse(), Base::MatrixPy::staticCallback_inverse(), Base::RotationPy::staticCallback_invert(), Base::MatrixPy::staticCallback_invert(), Base::BoundBoxPy::staticCallback_isCutPlane(), Base::BaseClassPy::staticCallback_isDerivedFrom(), Base::BoundBoxPy::staticCallback_isInside(), Base::BoundBoxPy::staticCallback_isIntersection(), Base::PlacementPy::staticCallback_move(), Base::MatrixPy::staticCallback_move(), Base::BoundBoxPy::staticCallback_move(), Base::VectorPy::staticCallback_multiply(), Base::RotationPy::staticCallback_multiply(), Base::PlacementPy::staticCallback_multiply(), Base::MatrixPy::staticCallback_multiply(), Base::RotationPy::staticCallback_multVec(), Base::PlacementPy::staticCallback_multVec(), Base::VectorPy::staticCallback_normalize(), Base::VectorPy::staticCallback_projectToLine(), Base::VectorPy::staticCallback_projectToPlane(), Base::MatrixPy::staticCallback_rotateX(), Base::MatrixPy::staticCallback_rotateY(), Base::MatrixPy::staticCallback_rotateZ(), Base::VectorPy::staticCallback_scale(), Base::MatrixPy::staticCallback_scale(), Base::VectorPy::staticCallback_sub(), Base::RotationPy::staticCallback_toEuler(), Base::PlacementPy::staticCallback_toMatrix(), Base::MatrixPy::staticCallback_transform(), Base::MatrixPy::staticCallback_unity(), and Base::RedirectStdError::sync().

ConsoleObserver * ConsoleSingleton::Get ( const char *  Name  ) 
ConsoleSingleton & ConsoleSingleton::Instance ( void   )  [static]

singleton

Definition at line 337 of file Console.cpp.

References ConsoleSingleton().

Referenced by Base::Console(), sPyError(), sPyGetStatus(), sPyLog(), sPyMessage(), sPySetStatus(), and sPyWarning().

void ConsoleSingleton::Log ( const char *  pMsg,
  ... 
) [virtual]

Prints a log Message.

Prints a Message this method is more for devlopment and tracking purpos.

It can be used to track execution of algorithems and functions and put it in files. The normal user dont need to see it, its more for developers and experinced users. So in normal user modes the logging is switched of.

You can use a printf like interface like:
  Console().Log("Exectue part %d in algorithem %s\n",i,str);
See also:
Message
Warning
Error

Definition at line 225 of file Console.cpp.

References _bVerbose, format, and format_len.

Referenced by Base::PyObjectBase::_repr(), App::PropertyFileIncluded::Copy(), Base::Type::createInstanceByName(), App::Application::destruct(), App::Application::processCmdLineFiles(), Base::PyObjectBase::PyObjectBase(), App::Application::runApplication(), Sketcher::Sketch::solve(), sPyLog(), Base::RedirectStdLog::sync(), Base::RedirectStdOutput::sync(), and Base::PyObjectBase::~PyObjectBase().

void ConsoleSingleton::Message ( const char *  pMsg,
  ... 
) [virtual]

Prints a Message.

Prints a Message This method issues a Message.

Messages are used show some non vital information. That means in the case FreeCAD running with GUI a Message in the status Bar apear. In console mode a message comes out.

You can use a printf like interface like:
  Console().Message("Doing somthing important %d times\n",i);
See also:
Warning
Error
Log

Definition at line 150 of file Console.cpp.

References format, and format_len.

Referenced by sPyMessage().

ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType ( const char *  sObs,
ConsoleMsgFlags  type,
bool  b 
)

Enables or disables message types of a cetain console observer.

type can be OR'ed with any of the FreeCAD_ConsoleMsgType flags to enable -- if b is true -- or to disable -- if b is false -- a console observer with name sObs.

The return value is an OR'ed value of all message types that have changed their state. For example

 // switch off warnings and error messages
 ConsoleMsgFlags ret = Base::Console().SetEnabledMsgType("myObs", 
                             ConsoleMsgType::MsgType_Wrn|ConsoleMsgType::MsgType_Err, false);
 // do something without notifying observer myObs
 ...
 // restore the former configuration again
 Base::Console().SetEnabledMsgType("myObs", ret, true);

switches off warnings and error messages and restore the state before the modification. If the observer sObs doesn't exist then nothing happens.

Definition at line 103 of file Console.cpp.

References Base::ConsoleObserver::bErr, Base::ConsoleObserver::bLog, Base::ConsoleObserver::bMsg, Base::ConsoleObserver::bWrn, Get(), MsgType_Err, MsgType_Log, MsgType_Txt, and MsgType_Wrn.

void ConsoleSingleton::SetMode ( ConsoleMode  m  ) 

Change mode.

sets the console in a special mode

Definition at line 73 of file Console.cpp.

References _bVerbose, and Verbose.

PyObject * ConsoleSingleton::sPyError ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 434 of file Console.cpp.

References Error(), Instance(), PY_CATCH, and PY_TRY.

PyObject * ConsoleSingleton::sPyGetStatus ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * ConsoleSingleton::sPyLog ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 467 of file Console.cpp.

References Instance(), Log(), PY_CATCH, and PY_TRY.

PyObject * ConsoleSingleton::sPyMessage ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 368 of file Console.cpp.

References Instance(), Message(), PY_CATCH, and PY_TRY.

PyObject * ConsoleSingleton::sPySetStatus ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]
PyObject * ConsoleSingleton::sPyWarning ( PyObject self,
PyObject args,
PyObject kwd 
) [static, protected]

Definition at line 401 of file Console.cpp.

References Instance(), PY_CATCH, PY_TRY, and Warning().

const char * ConsoleSingleton::Time ( void   ) 

Delivers a time/date string.

Delivers the time/date this method give you a string with the actual time/date.

You can use that for Log() calls to make time stamps.

Returns:
Const string with the date/time

Definition at line 243 of file Console.cpp.

void ConsoleSingleton::UnsetMode ( ConsoleMode  m  ) 

Change mode.

unsets the console from a special mode

Definition at line 81 of file Console.cpp.

References _bVerbose, and Verbose.

void ConsoleSingleton::Warning ( const char *  pMsg,
  ... 
) [virtual]

Prints a warning Message.

Prints a Message This method issues a Warning.

Messages are used to get the users attantion. That means in the case FreeCAD running with GUI a Message Box is poping up. In console mode a colored message comes out! So dont use careless. For information purpose the Log or Message method is more aprobiated.

You can use a printf like interface like:
  Console().Warning("Some defects in %s, loading anyway\n",str);
See also:
Message
Error
Log

Definition at line 174 of file Console.cpp.

References format, and format_len.

Referenced by Sketcher::Sketch::addDistanceConstraint(), Sketcher::Sketch::addEqualConstraint(), Sketcher::Sketch::addPerpendicularConstraint(), Sketcher::Sketch::addTangentConstraint(), ParameterGrp::Clear(), Base::ConsoleObserverFile::ConsoleObserverFile(), App::Application::processCmdLineFiles(), Base::ScriptFactorySingleton::ProduceScript(), App::PropertyLinkSubList::Restore(), App::PropertyLinkList::Restore(), App::PropertyLinkSub::Restore(), App::PropertyLink::Restore(), Sketcher::Sketch::solve(), sPyWarning(), and Sketcher::Sketch::toShape().


Member Data Documentation

Definition at line 163 of file Console.h.

Referenced by Log(), SetMode(), and UnsetMode().

PyMethodDef ConsoleSingleton::Methods [static]
Initial value:
 {
    {"PrintMessage",         (PyCFunction) ConsoleSingleton::sPyMessage, 1, 
     "PrintMessage(string) -- Print a message to the output"},
    {"PrintLog",             (PyCFunction) ConsoleSingleton::sPyLog, 1,
     "PrintLog(string) -- Print a log message to the output"},
    {"PrintError"  ,         (PyCFunction) ConsoleSingleton::sPyError, 1,
     "PrintError(string) -- Print an error message to the output"},
    {"PrintWarning",         (PyCFunction) ConsoleSingleton::sPyWarning, 1,
     "PrintWarning -- Print a warning to the output"},
    {"SetStatus",            (PyCFunction) ConsoleSingleton::sPySetStatus, 1,
     "Set the status for either Log, Msg, Wrn or Error for an observer"},
    {"GetStatus",            (PyCFunction) ConsoleSingleton::sPyGetStatus, 1,
     "Get the status for either Log, Msg, Wrn or Error for an observer"},
    {NULL, NULL, 0, NULL}               
}

Definition at line 151 of file Console.h.


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

Generated on Wed Nov 23 19:01:46 2011 for FreeCAD by  doxygen 1.6.1