![]() |
appkit
1.5.1
RoadNarrows Robotics Application Kit
|
Classes | |
| struct | BookMark |
| Log bookmark structure. More... | |
| struct | Entry |
| Log entry structure. More... | |
Public Types | |
| typedef std::vector< Entry > | EntryList |
| entry list type | |
| typedef EntryList::iterator | EntryListIter |
| entry list iterator | |
| typedef EntryList::const_iterator | EntryListCIter |
| entry const list iterator | |
| typedef std::vector< BookMark > | BookMarkList |
| bookmark list type | |
| typedef BookMarkList::iterator | BookMarkListIter |
| bookmark list iterator | |
| typedef BookMarkList::const_iterator | BookMarkListCIter |
| bookmark const list iter | |
Public Member Functions | |
| LogBook (const std::string strName="Log Book", size_t uMaxEntries=MaxEntriesDft, size_t uMaxEntryLen=MaxEntryLenDft) | |
| Default initialization constructor. More... | |
| LogBook (const LogBook &src) | |
| Copy constructor. More... | |
| virtual | ~LogBook () |
| Destructor. | |
| LogBook & | operator= (const LogBook &rhs) |
| Assignment operator. More... | |
| LogBook & | operator<< (bool val) |
| LogBook & | operator<< (char val) |
| LogBook & | operator<< (int val) |
| LogBook & | operator<< (unsigned int val) |
| LogBook & | operator<< (long val) |
| LogBook & | operator<< (unsigned long val) |
| LogBook & | operator<< (long long val) |
| LogBook & | operator<< (unsigned long long val) |
| LogBook & | operator<< (float val) |
| LogBook & | operator<< (double val) |
| LogBook & | operator<< (long double val) |
| LogBook & | operator<< (const char *val) |
| LogBook & | operator<< (void *val) |
| LogBook & | operator<< (const std::string &val) |
| LogBook & | operator<< (const LogBook &log) |
| LogBook & | operator<< (LogBook &(*pf)(LogBook &)) |
| LogBook & | operator<< (std::ostream &(*pf)(std::ostream &)) |
| LogBook & | operator<< (std::ios &(*pf)(std::ios &)) |
| LogBook & | operator<< (std::ios_base &(*pf)(std::ios_base &)) |
| size_t | logEntry (const std::string strText, const std::string strMark="") |
| Log the given entry into the log book. More... | |
| size_t | logPending () |
| Log any pending entry into the log book. More... | |
| void | setPendingText (const std::string strText) |
| Set the pending log text. More... | |
| void | setPendingBookMark (const std::string strMark) |
| Set the pending bookmark. More... | |
| void | setPending (const std::string strText, const std::string strMark) |
| Set the pending log text and associated bookmark. More... | |
| void | erasePendingText () |
| Erase the pending log text. | |
| void | erasePendingBookMark () |
| Erase the pending log bookmark. | |
| void | erasePending () |
| Erase the pending log text and associated bookmark. | |
| size_t | eraseToMark (const std::string strMark, int whence) |
| Erases all entries from the log book up to the bookmark. More... | |
| size_t | eraseEntries (size_t uNumEntries, int whence) |
| Erases a given number of entries from the log book. More... | |
| void | clear () |
| Clear the log book and bookmarks, along with any pending entry. | |
| const Entry & | at (const std::string &strMark) const |
| Get the entry at the bookmark. More... | |
| const Entry & | at (const size_t index) const |
| Get the entry at the index. More... | |
| const Entry & | at (const size_t index, int whence) const |
| Get the entry at relative index from whence. More... | |
| const Entry & | operator[] (const size_t index) const |
| Log book array index operator. More... | |
| const Entry & | operator[] (const std::string &strMark) const |
| Log book array mark operator. More... | |
| const Entry & | lastEntry () const |
| Get the last (latest) log entry. More... | |
| const std::string & | textAt (const std::string &strMark) const |
| Get the entry text at the bookmark. More... | |
| const std::string & | textAt (const size_t index) const |
| Get the entry text at the index. More... | |
| const std::string & | textAt (const size_t index, int whence) const |
| Get the entry text at relative index from whence. More... | |
| const std::string & | lastText () const |
| Get the last (latest) log entry text. More... | |
| size_t | getBookMarks (BookMarkList &list, int whence) const |
| Get a sorted list of bookmark labels. More... | |
| bool | hasBookMark (const std::string &strMark) const |
| Test if bookmark exists in log book. More... | |
| const std::string & | getName () const |
| Get the name of the log book. More... | |
| void | setName (const std::string &strName) |
| Set the name of the log book. More... | |
| const size_t | max_size () const |
| Return the maximum number entries the log book can hold. More... | |
| size_t | size () const |
| Return the number of logged entries in the log book. More... | |
| void | resize (size_t uMaxEntries) |
| Resize maximum size of log book. More... | |
| size_t | numOfTotalEver () const |
| Return the total number of entries ever added during log book's life. More... | |
| unsigned | getFlags () const |
| Get the current formatting flags. More... | |
| unsigned | setFlags (const unsigned uFlags) |
| Set the current formatting flags. More... | |
| unsigned | orFlags (const unsigned uFlags) |
| Or new flags into the current formatting flags. More... | |
| unsigned | compAndFlags (const unsigned uFlags) |
| Apply one's Complement and And into the current formatting flags. More... | |
| void | clearFlags () |
| Clear alll current formatting flags. | |
| std::string | makeBookMarkLabel () |
| Generate a unique bookmark label. More... | |
| std::ostream & | printLog (std::ostream &os) const |
| Print the entire log book to the output stream. More... | |
| std::ostream & | printToMark (std::ostream &os, const std::string strMark, int endpt) const |
| Print the log book entires between the bookmark and the specified end point to the output stream. More... | |
Static Public Attributes | |
| static const size_t | MaxEntriesDft = 100 |
| max num entries default | |
| static const size_t | MaxEntryLenDft = 0x2000 |
| max entry length (8192) | |
| static const int | OLDEST = 0 |
| oldest entries | |
| static const int | NEWEST = 1 |
| newest, most recent entries | |
| static const unsigned | FlagNone = 0x0000 |
| no flags | |
| static const unsigned | FlagONum = 0x0001 |
| output log entry number | |
| static const unsigned | FlagOTime = 0x0002 |
| output log entry time | |
| static const unsigned | FlagOMark = 0x0004 |
| output log entry bookmarks | |
| static const unsigned | FlagOAllF = 0x0007 |
| output all entry fields | |
| static const unsigned | FlagORev = 0x0008 |
| output log reverse order | |
| static const unsigned | FlagDebug = 0x1000 |
| debug | |
Protected Types | |
| typedef std::deque< Entry > | BookDeq |
| book type | |
| typedef BookDeq::iterator | BookIter |
| book iterator | |
| typedef BookDeq::const_iterator | BookCIter |
| book const iterator | |
| typedef BookDeq::reverse_iterator | BookRIter |
| reverse book iter | |
| typedef BookDeq::const_reverse_iterator | BookCRIter |
| const rev book iter | |
Protected Member Functions | |
| void | limitSize () |
| Limit size of log book to defined limit. | |
| void | ssflush () |
| Flush the pending text stream. More... | |
| bool | checkLen (size_t uEstLen=1) |
| Check the length of the pending entry. More... | |
| BookIter | findMark (const std::string &strMark) |
| Find position it log book of the bookmarked entry. More... | |
| BookCIter | findMark (const std::string &strMark) const |
| Find position it log book of the bookmarked entry. More... | |
| void | sortMarks (BookMarkList &sorted) const |
| Sort bookmarks from oldest to newest. More... | |
| void | rsortMarks (BookMarkList &sorted) const |
| Reverse sort bookmarks from newest to oldest. More... | |
| void | copy (const LogBook &src) |
| Copy log book verbatim to this log book. More... | |
| void | prt (std::ostream &os, size_t index0, size_t index1) const |
| Print log book from index 0 to index 1, inclusive. More... | |
| void | rprt (std::ostream &os, size_t index0, size_t index1) const |
| Reverse print log book from index 1 to index 0, inclusive. More... | |
Protected Attributes | |
| std::string | m_strName |
| name of log | |
| size_t | m_uMaxEntries |
| maximum number of log entries | |
| size_t | m_uMaxEntryLen |
| maximum entry length | |
| size_t | m_uTotalEver |
| total entries added during lifetime | |
| unsigned | m_uFlags |
| formatting flags | |
| bool | m_bWarnThrottle |
| do [not] throttle warnings | |
| std::string | m_strMark |
| pending bookmark label | |
| std::stringstream | m_ssText |
| pending text stream | |
| BookDeq | m_book |
| the log book | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const LogBook &log) |
| Stream insertion operator. More... | |
| LogBook::LogBook | ( | const std::string | strName = "Log Book", |
| size_t | uMaxEntries = MaxEntriesDft, |
||
| size_t | uMaxEntryLen = MaxEntryLenDft |
||
| ) |
Default initialization constructor.
| strName | Name of log book. |
| uMaxEntries | Maximum number of entries in log book. |
| uMaxEntryLen | Maximum entry length. |
Definition at line 148 of file LogBook.cxx.
References FlagONum, m_bWarnThrottle, m_uFlags, and m_uTotalEver.
| LogBook::LogBook | ( | const LogBook & | src | ) |
Copy constructor.
| src | Source object. |
Definition at line 161 of file LogBook.cxx.
References copy().
| const Entry& rnr::LogBook::at | ( | const std::string & | strMark | ) | const |
Get the entry at the bookmark.
| strMark | Bookmark label. |
Referenced by clear(), operator[](), and textAt().
| const LogBook::Entry & LogBook::at | ( | const size_t | index | ) | const |
Get the entry at the index.
| index | Log book absolute index. |
Definition at line 544 of file LogBook.cxx.
References m_book, and size().
| const LogBook::Entry & LogBook::at | ( | const size_t | index, |
| int | whence | ||
| ) | const |
Get the entry at relative index from whence.
| index | Relative log book index. |
| whence | Whence directive (OLDEST or NEWEST). |
Definition at line 556 of file LogBook.cxx.
References m_book, NEWEST, and size().
|
protected |
Check the length of the pending entry.
| uEstLen | Estimated length of the new object text to be added. |
Definition at line 804 of file LogBook.cxx.
References findMark(), m_book, m_bWarnThrottle, m_ssText, and m_uMaxEntryLen.
Referenced by operator=().
|
inline |
|
protected |
Copy log book verbatim to this log book.
| src | Source log book. |
Definition at line 911 of file LogBook.cxx.
References m_book, m_strName, m_uFlags, m_uMaxEntries, m_uMaxEntryLen, and m_uTotalEver.
Referenced by LogBook(), and operator=().
| size_t LogBook::eraseEntries | ( | size_t | uNumEntries, |
| int | whence | ||
| ) |
Erases a given number of entries from the log book.
If whence is OLDEST, then the entries are erased starting from the oldest entry.
If whence is NEWEST, then the entries are erased starting from the most recent entry.
| uNumEntries | Number of entries to delete. If >= number of entries, then the book is erased. |
| whence | Whence directive (OLDEST or NEWEST). |
Definition at line 483 of file LogBook.cxx.
References m_book, NEWEST, OLDEST, and size().
Referenced by limitSize().
| size_t LogBook::eraseToMark | ( | const std::string | strMark, |
| int | whence | ||
| ) |
Erases all entries from the log book up to the bookmark.
If whence is OLDEST, then the entries erased are from the oldest entries up to, but not including, the first encounter of the bookmarked entry.
If whence is NEWEST, then the entries erased are from the most recent logged entry up to and including the first encounter of the bookmarked entry.
If the bookmark is not found, then no entries are erased.
| strMark | Bookmark search label. |
| whence | Whence directive (OLDEST or NEWEST). |
Definition at line 457 of file LogBook.cxx.
References findMark(), m_book, NEWEST, OLDEST, and size().
|
protected |
Find position it log book of the bookmarked entry.
The search starts at the oldest entry.
| strMark | Bookmark search label. |
Referenced by checkLen(), clear(), eraseToMark(), hasBookMark(), and printToMark().
|
protected |
Find position it log book of the bookmarked entry.
Constant version.
The search starts at the oldest entry.
| strMark | Bookmark search label. |
| size_t LogBook::getBookMarks | ( | BookMarkList & | list, |
| int | whence | ||
| ) | const |
Get a sorted list of bookmark labels.
If whence is OLDEST, then sort from oldest to newest. If whence is NEWEST, then sort from most recent to oldest.
| [out] | list | List of sorted bookmark labels. |
| whence | Whence directive (OLDEST or NEWEST). |
Definition at line 594 of file LogBook.cxx.
References NEWEST, OLDEST, rsortMarks(), and sortMarks().
Referenced by lastText(), and mainInit().
|
inline |
Get the current formatting flags.
Definition at line 618 of file LogBook.h.
References m_uFlags.
Referenced by mainInit().
|
inline |
Get the name of the log book.
Definition at line 558 of file LogBook.h.
References m_strName.
Referenced by mainInit().
|
inline |
Test if bookmark exists in log book.
| strMark | Bookmark label. |
Definition at line 548 of file LogBook.h.
References findMark(), and m_book.
| const LogBook::Entry & LogBook::lastEntry | ( | ) | const |
Get the last (latest) log entry.
Definition at line 581 of file LogBook.cxx.
References m_book, and size().
Referenced by lastText().
|
inline |
Get the last (latest) log entry text.
Definition at line 523 of file LogBook.h.
References getBookMarks(), lastEntry(), and rnr::LogBook::Entry::m_strText.
Referenced by rnr::cmd::CommandLine::getErrorStr().
| size_t LogBook::logEntry | ( | const std::string | strText, |
| const std::string | strMark = "" |
||
| ) |
Log the given entry into the log book.
Any pending log entry remains untouched.
| strText | Log entry text. |
| strMark | Associated log entry bookmark. If empty (""), then no bookmark added. |
Definition at line 370 of file LogBook.cxx.
References FlagDebug, limitSize(), m_book, m_uFlags, m_uTotalEver, and size().
| size_t LogBook::logPending | ( | ) |
Log any pending entry into the log book.
The pending entry and associated bookmark are recorded into log. The pending data are then erased.
Definition at line 392 of file LogBook.cxx.
References erasePending(), FlagDebug, limitSize(), m_book, m_ssText, m_strMark, m_uFlags, m_uTotalEver, and size().
Referenced by rnr::eoe().
| std::string LogBook::makeBookMarkLabel | ( | ) |
Generate a unique bookmark label.
Definition at line 612 of file LogBook.cxx.
References m_uTotalEver, rnr::operator<<(), and printLog().
Referenced by rnr::bookmark(), and clearFlags().
|
inline |
Return the maximum number entries the log book can hold.
Definition at line 578 of file LogBook.h.
References m_uMaxEntries.
Referenced by mainInit().
|
inline |
Return the total number of entries ever added during log book's life.
Definition at line 608 of file LogBook.h.
References m_uTotalEver.
Referenced by mainInit().
Assignment operator.
| rhs | Right-hand side object. |
Definition at line 170 of file LogBook.cxx.
References checkLen(), copy(), limitSize(), m_book, m_ssText, m_uTotalEver, and size().
| const LogBook::Entry & LogBook::operator[] | ( | const size_t | index | ) | const |
Log book array index operator.
Get the entry at the index.
| index | Log book absolute index. |
Definition at line 571 of file LogBook.cxx.
References at().
| const Entry& rnr::LogBook::operator[] | ( | const std::string & | strMark | ) | const |
Log book array mark operator.
| strMark | Bookmark label. |
|
inline |
Or new flags into the current formatting flags.
| uFlags | Flags to or into bit list of flags. |
Definition at line 643 of file LogBook.h.
References m_uFlags.
Referenced by mainInit().
| ostream & LogBook::printLog | ( | std::ostream & | os | ) | const |
Print the entire log book to the output stream.
The output is controlled by the current formatting flag bits.
* LogBook * entry_0 | ^ <-- oldest end point * entry_1 | | * ... | | * entry_n-1 v | <-- newest end point * \ \ * \ \ * \ reverse order * \ * forward order *
| os | Output stream. |
Definition at line 630 of file LogBook.cxx.
References FlagORev, m_uFlags, prt(), rprt(), and size().
Referenced by rnr::cmd::CommandLine::backtrace(), clearFlags(), and makeBookMarkLabel().
| ostream & LogBook::printToMark | ( | std::ostream & | os, |
| const std::string | strMark, | ||
| int | endpt | ||
| ) | const |
Print the log book entires between the bookmark and the specified end point to the output stream.
The output is controlled by the current formatting flag bits.
If the opposite end point to the mark is the oldest entry, then the bookmark entry is excluded. Otherwise it is included.
* LogBook * entry_0 | ^ <-- oldest end point * entry_1 | | * ... | | * entry_k-1 v | <-- sans mark end point * * entry_k | ^ <-- mark end point * entry_k+1 | | * ... | | * entry_n-1 v | <-- newest end point * \ \ * \ \ * \ reverse order * \ * forward order *
| os | Output stream. |
| strMark | Bookmark search label. |
| endpt | Opposite end point to mark (OLDEST or NEWEST). |
Definition at line 646 of file LogBook.cxx.
References findMark(), FlagORev, m_book, m_uFlags, OLDEST, prt(), rprt(), and size().
Referenced by rnr::cmd::CommandLine::backtrace(), and clearFlags().
|
protected |
Print log book from index 0 to index 1, inclusive.
The output is controlled by the current formatting flag bits.
| os | Output stream. |
| index0 | Starting log book index. |
| index1 | Ending log book index. |
Definition at line 688 of file LogBook.cxx.
References FlagDebug, FlagOMark, FlagONum, FlagOTime, m_book, m_uFlags, and size().
Referenced by printLog(), and printToMark().
| void LogBook::resize | ( | size_t | uMaxEntries | ) |
Resize maximum size of log book.
If the new size is smaller, then entries may be deleted.
| uMaxEntries | Maximum number of entries in log book. |
Definition at line 512 of file LogBook.cxx.
References limitSize(), and m_uMaxEntries.
Referenced by size().
|
protected |
Reverse print log book from index 1 to index 0, inclusive.
The output is controlled by the current formatting flag bits.
| os | Output stream. |
| index0 | Starting log book index. |
| index1 | Ending log book index. |
Definition at line 734 of file LogBook.cxx.
References FlagDebug, FlagOMark, FlagONum, FlagOTime, m_book, m_uFlags, and size().
Referenced by printLog(), and printToMark().
|
protected |
Reverse sort bookmarks from newest to oldest.
| [out] | sorted | List of sorted bookmarks. |
Definition at line 881 of file LogBook.cxx.
References rnr::bookmark(), clear(), FlagDebug, m_book, m_uFlags, and size().
Referenced by getBookMarks().
|
inline |
Set the current formatting flags.
| uFlags | Flags to set. |
Definition at line 630 of file LogBook.h.
References m_uFlags.
Referenced by mainInit(), and rnr::operator<<().
|
inline |
Set the name of the log book.
| strName | String. |
Definition at line 568 of file LogBook.h.
References m_strName.
Referenced by mainInit().
| void LogBook::setPending | ( | const std::string | strText, |
| const std::string | strMark | ||
| ) |
Set the pending log text and associated bookmark.
| strText | Log entry text. |
| strMark | Associated log entry bookmark label. |
Definition at line 435 of file LogBook.cxx.
References setPendingBookMark(), and setPendingText().
| void LogBook::setPendingBookMark | ( | const std::string | strMark | ) |
Set the pending bookmark.
The pending bookmark is associated with the pending log entry. Any previous pending, unlogged bookmark will be lost.
| strMark | Pending bookmark label. |
Definition at line 430 of file LogBook.cxx.
References m_strMark.
Referenced by rnr::bookmark(), rnr::operator<<(), and setPending().
| void LogBook::setPendingText | ( | const std::string | strText | ) |
Set the pending log text.
Any previously pending, unlogged text will be lost.
| strText | Log entry text. |
Definition at line 423 of file LogBook.cxx.
References m_ssText, and ssflush().
Referenced by setPending().
|
inline |
Return the number of logged entries in the log book.
Definition at line 588 of file LogBook.h.
References m_book, and resize().
Referenced by at(), eraseEntries(), eraseToMark(), lastEntry(), logEntry(), logPending(), mainInit(), operator=(), printLog(), printToMark(), prt(), rprt(), and rsortMarks().
|
protected |
Sort bookmarks from oldest to newest.
| [out] | sorted | List of sorted bookmarks. |
Definition at line 851 of file LogBook.cxx.
References rnr::bookmark(), clear(), FlagDebug, m_book, and m_uFlags.
Referenced by getBookMarks().
|
protected |
Flush the pending text stream.
The bytes go to a better place, not the log.
Definition at line 797 of file LogBook.cxx.
References m_bWarnThrottle, and m_ssText.
Referenced by erasePending(), erasePendingText(), and setPendingText().
|
inline |
Get the entry text at the bookmark.
| strMark | Bookmark label. |
Definition at line 482 of file LogBook.h.
References at(), and rnr::LogBook::Entry::m_strText.
Referenced by mainInit().
|
inline |
Get the entry text at the index.
| index | Log book absolute index. |
Definition at line 496 of file LogBook.h.
References at(), and rnr::LogBook::Entry::m_strText.
|
inline |
Get the entry text at relative index from whence.
| index | Relative log book index. |
| whence | Whence directive (OLDEST or NEWEST). |
Definition at line 511 of file LogBook.h.
References at(), and rnr::LogBook::Entry::m_strText.
|
friend |
Stream insertion operator.
The entire log book is inserted. Formatting is controlled by the current flags settings.
| os | Output stream. |
| log | Log book. |