Main MRPT website > C++ reference
MRPT logo
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
mrpt::utils::CLog Class Reference

Detailed Description

A decorator of CStringList special for keeping logs.

Note:
Class written by Vicente Arevalo

#include <mrpt/utils/CLog.h>

Inheritance diagram for mrpt::utils::CLog:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CLog ()
virtual ~CLog ()
void pushMessages (std::string message)
 push a message
void pushMessages (mrpt::utils::CStringList messages)
 push a list of messages
void popMessages (std::string &message)
 pop the current unpublished message (clear the content of "message")
void popMessages (mrpt::utils::CStringList &messages)
 pop all unpublished messages (clear the content of "messages")
void getMessages (size_t begin, size_t end, mrpt::utils::CStringList &messages)
 get messages from "begin" to "end" (clear the content of "messages")
void saveLog (std::string name)
 save the current log
void loadLog (std::string name)
 load a log (clear the previous content)
void clearLog ()
 clear the log content
void setLastMessageIndex (size_t index)
 change the last unpublished message.
size_t getLastMessageIndex ()
 get the current unpublished message index.

Protected Member Functions

void add (const std::string &str)
 Appends a new string at the end of the string list.
CStringListoperator<< (const std::string &s)
 An alternative way of adding strings to the list.
void insert (size_t index, const std::string &str)
 Inserts a new item at a given position (0=insert at the beggining,1=put into the second position,...)
void set (size_t index, const std::string &str)
 Overwrites an existing position with a new value (0=first elements)
void set (const std::string &keyName, const std::string &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed.
void set (const std::string &keyName, const int &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed.
void set (const std::string &keyName, const float &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed.
void set (const std::string &keyName, const double &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed.
void set (const std::string &keyName, const bool &value)
 Sets the value of a given key ("key=value"), overwritten previous value if it existed.
void clear ()
 Clear the whole list.
size_t size () const
 Returns the number of text lines in the list.
void remove (size_t index)
 Delete the element at a given position (0=first element)
bool find (const std::string &compareText, size_t foundIndex, bool caseSensitive=true) const
 Looks for a given string in the list, and returns its index, or returns "false" otherwise.
void get (size_t index, std::string &outText) const
 Returns one string from the line list.
std::string operator() (size_t index) const
 Returns one string from the line list.
std::stringoperator() (size_t index)
 Returns a reference to one string from the line list.
void getText (std::string &outText) const
 Returns the whole string list as a single string with '
' characters for newlines.
std::string getText () const
 Returns the whole string list as a single string with '
' characters for newlines.
void setText (const std::string &inText)
 Fills the string list by parsing a single string with '', '
', or '
' characters indicatng newlines.
void loadFromFile (const std::string &fileName)
 Load the string list from a file.
void saveToFile (const std::string &fileName) const
 Save the string list to a file.
std::string get_string (const std::string &keyName)
 Returns the value of the given key ("key=value").
float get_float (const std::string &keyName)
 Returns the value of the given key ("key=value").
int get_int (const std::string &keyName)
 Returns the value of the given key ("key=value").
double get_double (const std::string &keyName)
 Returns the value of the given key ("key=value").
bool get_bool (const std::string &keyName)
 Returns the value of the given key ("key=value").
virtual void writeToStream (mrpt::utils::CStream &out, int *getVersion) const =0
 Introduces a pure virtual method responsible for writing to a CStream.
virtual void readFromStream (mrpt::utils::CStream &in, int version)=0
 Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.
mrpt::utils::CObjectPtr duplicateGetSmartPtr () const
 Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).
CObjectclone () const
 Cloning interface for smart pointers.

Protected Attributes

mrpt::synch::CCriticalSection semaphore
size_t last
std::deque< std::stringm_strings
 The internal list of strings.

Static Protected Attributes

static const
mrpt::utils::TRuntimeClassId 
classCObject

RTTI stuff

static const
mrpt::utils::TRuntimeClassId 
classCSerializable
class mrpt::utils::CStream

RTTI stuff

typedef CStringListPtr SmartPtr
static mrpt::utils::CLASSINIT _init_CStringList
static mrpt::utils::TRuntimeClassId classCStringList
static const
mrpt::utils::TRuntimeClassId
classinfo
static const
mrpt::utils::TRuntimeClassId
_GetBaseClass ()
static mrpt::utils::CObjectCreateObject ()
static CStringListPtr Create ()
virtual const
mrpt::utils::TRuntimeClassId
GetRuntimeClass () const
 Returns information about the class of an object in runtime.
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class.

Member Typedef Documentation

A typedef for the associated smart pointer

Definition at line 53 of file CStringList.h.


Constructor & Destructor Documentation

mrpt::utils::CLog::CLog ( )
virtual mrpt::utils::CLog::~CLog ( ) [virtual]

Member Function Documentation

static const mrpt::utils::TRuntimeClassId* mrpt::utils::CStringList::_GetBaseClass ( ) [static, protected, inherited]

Reimplemented from mrpt::utils::CSerializable.

void mrpt::utils::CStringList::add ( const std::string str) [inherited]

Appends a new string at the end of the string list.

See also:
insert,set
void mrpt::utils::CStringList::clear ( ) [inherited]

Clear the whole list.

void mrpt::utils::CLog::clearLog ( )

clear the log content

CObject* mrpt::utils::CObject::clone ( ) const [inline, inherited]

Cloning interface for smart pointers.

Reimplemented in mrpt::opengl::CRenderizable, and mrpt::opengl::CRenderizableDisplayList.

Definition at line 154 of file CObject.h.

static CStringListPtr mrpt::utils::CStringList::Create ( ) [static, inherited]
static mrpt::utils::CObject* mrpt::utils::CStringList::CreateObject ( ) [static, inherited]
virtual mrpt::utils::CObject* mrpt::utils::CStringList::duplicate ( ) const [virtual, inherited]

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

mrpt::utils::CObjectPtr mrpt::utils::CObject::duplicateGetSmartPtr ( ) const [inline, inherited]

Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).

Definition at line 151 of file CObject.h.

bool mrpt::utils::CStringList::find ( const std::string compareText,
size_t  foundIndex,
bool  caseSensitive = true 
) const [inherited]

Looks for a given string in the list, and returns its index, or returns "false" otherwise.

Returns:
true if string has been found.
void mrpt::utils::CStringList::get ( size_t  index,
std::string outText 
) const [inherited]

Returns one string from the line list.

bool mrpt::utils::CStringList::get_bool ( const std::string keyName) [inherited]

Returns the value of the given key ("key=value").

Exceptions:
std::exceptionIf the key is not found in the string list.
double mrpt::utils::CStringList::get_double ( const std::string keyName) [inherited]

Returns the value of the given key ("key=value").

Exceptions:
std::exceptionIf the key is not found in the string list.
float mrpt::utils::CStringList::get_float ( const std::string keyName) [inherited]

Returns the value of the given key ("key=value").

Exceptions:
std::exceptionIf the key is not found in the string list.
int mrpt::utils::CStringList::get_int ( const std::string keyName) [inherited]

Returns the value of the given key ("key=value").

Exceptions:
std::exceptionIf the key is not found in the string list.
std::string mrpt::utils::CStringList::get_string ( const std::string keyName) [inherited]

Returns the value of the given key ("key=value").

Exceptions:
std::exceptionIf the key is not found in the string list.
size_t mrpt::utils::CLog::getLastMessageIndex ( )

get the current unpublished message index.

void mrpt::utils::CLog::getMessages ( size_t  begin,
size_t  end,
mrpt::utils::CStringList messages 
)

get messages from "begin" to "end" (clear the content of "messages")

virtual const mrpt::utils::TRuntimeClassId* mrpt::utils::CStringList::GetRuntimeClass ( ) const [virtual, inherited]

Returns information about the class of an object in runtime.

Reimplemented from mrpt::utils::CSerializable.

void mrpt::utils::CStringList::getText ( std::string outText) const [inherited]

Returns the whole string list as a single string with '
' characters for newlines.

std::string mrpt::utils::CStringList::getText ( ) const [inline, inherited]

Returns the whole string list as a single string with '
' characters for newlines.

Definition at line 134 of file CStringList.h.

void mrpt::utils::CStringList::insert ( size_t  index,
const std::string str 
) [inherited]

Inserts a new item at a given position (0=insert at the beggining,1=put into the second position,...)

See also:
add,set
void mrpt::utils::CStringList::loadFromFile ( const std::string fileName) [inherited]

Load the string list from a file.

void mrpt::utils::CLog::loadLog ( std::string  name)

load a log (clear the previous content)

std::string mrpt::utils::CStringList::operator() ( size_t  index) const [inherited]

Returns one string from the line list.

std::string& mrpt::utils::CStringList::operator() ( size_t  index) [inherited]

Returns a reference to one string from the line list.

CStringList& mrpt::utils::CStringList::operator<< ( const std::string s) [inline, inherited]

An alternative way of adding strings to the list.

Definition at line 84 of file CStringList.h.

void mrpt::utils::CLog::popMessages ( std::string message)

pop the current unpublished message (clear the content of "message")

void mrpt::utils::CLog::popMessages ( mrpt::utils::CStringList messages)

pop all unpublished messages (clear the content of "messages")

void mrpt::utils::CLog::pushMessages ( std::string  message)

push a message

void mrpt::utils::CLog::pushMessages ( mrpt::utils::CStringList  messages)

push a list of messages

virtual void mrpt::utils::CSerializable::readFromStream ( mrpt::utils::CStream in,
int  version 
) [protected, pure virtual, inherited]

Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.

Parameters:
inThe input binary stream where the object data must read from.
versionThe version of the object stored in the stream: use this version number in your code to know how to read the incoming data.
Exceptions:
std::exceptionOn any error, see CStream::ReadBuffer
See also:
CStream

Implemented in mrpt::math::CMatrixD, and mrpt::math::CMatrix.

void mrpt::utils::CStringList::remove ( size_t  index) [inherited]

Delete the element at a given position (0=first element)

void mrpt::utils::CLog::saveLog ( std::string  name)

save the current log

void mrpt::utils::CStringList::saveToFile ( const std::string fileName) const [inherited]

Save the string list to a file.

void mrpt::utils::CStringList::set ( size_t  index,
const std::string str 
) [inherited]

Overwrites an existing position with a new value (0=first elements)

See also:
insert
void mrpt::utils::CStringList::set ( const std::string keyName,
const std::string value 
) [inherited]

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

void mrpt::utils::CStringList::set ( const std::string keyName,
const int &  value 
) [inherited]

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

void mrpt::utils::CStringList::set ( const std::string keyName,
const float &  value 
) [inherited]

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

void mrpt::utils::CStringList::set ( const std::string keyName,
const double &  value 
) [inherited]

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

void mrpt::utils::CStringList::set ( const std::string keyName,
const bool &  value 
) [inherited]

Sets the value of a given key ("key=value"), overwritten previous value if it existed.

void mrpt::utils::CLog::setLastMessageIndex ( size_t  index)

change the last unpublished message.

IMPORTANT: this function should not be used directly.

void mrpt::utils::CStringList::setText ( const std::string inText) [inherited]

Fills the string list by parsing a single string with '', '
', or '
' characters indicatng newlines.

size_t mrpt::utils::CStringList::size ( ) const [inherited]

Returns the number of text lines in the list.

virtual void mrpt::utils::CSerializable::writeToStream ( mrpt::utils::CStream out,
int *  getVersion 
) const [protected, pure virtual, inherited]

Introduces a pure virtual method responsible for writing to a CStream.

This can not be used directly be users, instead use "stream << object;" for writing it to a stream.

Parameters:
outThe output binary stream where object must be dumped.
getVersionIf NULL, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data.
Exceptions:
std::exceptionOn any error, see CStream::WriteBuffer
See also:
CStream

Implemented in mrpt::math::CMatrixD, and mrpt::math::CMatrix.


Friends And Related Function Documentation

friend class mrpt::utils::CStream [friend, inherited]

Member Data Documentation

Definition at line 53 of file CStringList.h.

Definition at line 139 of file CObject.h.

Definition at line 56 of file CSerializable.h.

Definition at line 53 of file CStringList.h.

Definition at line 53 of file CStringList.h.

size_t mrpt::utils::CLog::last [protected]

Definition at line 104 of file CLog.h.

The internal list of strings.

Definition at line 58 of file CStringList.h.

Definition at line 102 of file CLog.h.




Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011