appkit  1.5.1
RoadNarrows Robotics Application Kit
LogBook.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_appkit
8 //
9 // File: LogBook.cxx
10 //
11 /*! \file
12  *
13  * \brief
14  *
15  * \author Robin Knight (robin.knight@roadnarrows.com)
16  *
17  * \par Copyright
18  * \h_copy 2017-2017. RoadNarrows LLC.\n
19  * http://www.roadnarrows.com\n
20  * All Rights Reserved
21  *
22  * \par License:
23  * MIT
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Permission is hereby granted, without written agreement and without
29  * license or royalty fees, to use, copy, modify, and distribute this
30  * software and its documentation for any purpose, provided that
31  * (1) The above copyright notice and the following two paragraphs
32  * appear in all copies of the source code and (2) redistributions
33  * including binaries reproduces these notices in the supporting
34  * documentation. Substantial modifications to this software may be
35  * copyrighted by their authors and need not follow the licensing terms
36  * described here, provided that the new terms are clearly indicated in
37  * all files where they apply.
38  *
39  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
40  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
41  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
42  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
43  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
44  * THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
48  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
49  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
50  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51  *
52  * @EulaEnd@
53  */
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #include <sys/types.h>
57 #include <sys/time.h>
58 #include <unistd.h>
59 #include <stdlib.h>
60 #include <stdio.h>
61 
62 #include <iostream>
63 #include <iomanip>
64 #include <sstream>
65 #include <string>
66 #include <deque>
67 #include <map>
68 #include <vector>
69 
70 #include "rnr/rnrconfig.h"
71 #include "rnr/log.h"
72 
73 #include "rnr/appkit/Time.h"
74 #include "rnr/appkit/LogBook.h"
75 
76 using namespace std;
77 using namespace rnr;
78 using namespace rnr::chronos;
79 //using rnr::chronos::operator<<;
80 
81 static timespec notime = {0, 0};
82 static LogBook::Entry noentry;
83 
84 
85 // -----------------------------------------------------------------------------
86 // Class LogBook::Entry
87 // -----------------------------------------------------------------------------
88 
89 LogBook::Entry::Entry() : m_timestamp(notime)
90 {
91 }
92 
93 LogBook::Entry::Entry(const string &strMark, const string &strText) :
94  m_strMark(strMark), m_strText(strText)
95 {
97 }
98 
100 {
101  m_timestamp = src.m_timestamp;
102  m_strMark = src.m_strMark;
103  m_strText = src.m_strText;
104 }
105 
107 {
108  m_timestamp = rhs.m_timestamp;
109  m_strMark = rhs.m_strMark;
110  m_strText = rhs.m_strText;
111 }
112 
114 {
115 }
116 
118 {
119  return m_strMark.empty() && m_strText.empty() && !isSet(m_timestamp);
120 }
121 
122 
123 // -----------------------------------------------------------------------------
124 // Class LogBook::BookMark
125 // -----------------------------------------------------------------------------
126 
128 {
129 }
130 
132 {
133  m_strMark = src.m_strMark;
134  m_index = src.m_index;
135 }
136 
138 {
139  m_strMark = rhs.m_strMark;
140  m_index = rhs.m_index;
141 }
142 
143 
144 // -----------------------------------------------------------------------------
145 // Class LogBook
146 // -----------------------------------------------------------------------------
147 
148 LogBook::LogBook(const std::string strName,
149  size_t uMaxEntries,
150  size_t uMaxEntryLen) :
151  m_strName(strName),
152  m_uMaxEntries(uMaxEntries),
153  m_uMaxEntryLen(uMaxEntryLen)
154 
155 {
156  m_uTotalEver = 0;
157  m_uFlags = FlagONum;
158  m_bWarnThrottle = false;
159 }
160 
162 {
163  copy(src);
164 }
165 
167 {
168 }
169 
171 {
172  copy(rhs);
173  return *this;
174 }
175 
176 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
177 // LogBook Insertion Operators
178 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
179 
180 LogBook &LogBook::operator<<(bool val)
181 {
182  if( checkLen() )
183  {
184  m_ssText << val;
185  }
186 
187  return *this;
188 }
189 
190 LogBook &LogBook::operator<<(char val)
191 {
192  if( checkLen() )
193  {
194  m_ssText << val;
195  }
196 
197  return *this;
198 }
199 
200 LogBook &LogBook::operator<<(int val)
201 {
202  if( checkLen() )
203  {
204  m_ssText << val;
205  }
206 
207  return *this;
208 }
209 
210 LogBook &LogBook::operator<<(unsigned int val)
211 {
212  if( checkLen() )
213  {
214  m_ssText << val;
215  }
216 
217  return *this;
218 }
219 
220 LogBook &LogBook::operator<<(long val)
221 {
222  if( checkLen() )
223  {
224  m_ssText << val;
225  }
226 
227  return *this;
228 }
229 
230 LogBook &LogBook::operator<<(unsigned long val)
231 {
232  if( checkLen() )
233  {
234  m_ssText << val;
235  }
236 
237  return *this;
238 }
239 
240 LogBook &LogBook::operator<<(long long val)
241 {
242  if( checkLen() )
243  {
244  m_ssText << val;
245  }
246 
247  return *this;
248 }
249 
250 LogBook &LogBook::operator<<(unsigned long long val)
251 {
252  if( checkLen() )
253  {
254  m_ssText << val;
255  }
256 
257  return *this;
258 }
259 
260 LogBook &LogBook::operator<<(float val)
261 {
262  if( checkLen() )
263  {
264  m_ssText << val;
265  }
266 
267  return *this;
268 }
269 
270 LogBook &LogBook::operator<<(double val)
271 {
272  if( checkLen() )
273  {
274  m_ssText << val;
275  }
276 
277  return *this;
278 }
279 
280 LogBook &LogBook::operator<<(long double val)
281 {
282  if( checkLen() )
283  {
284  m_ssText << val;
285  }
286 
287  return *this;
288 }
289 
290 LogBook &LogBook::operator<<(const char *val)
291 {
292  if( checkLen(strlen(val)) )
293  {
294  m_ssText << val;
295  }
296 
297  return *this;
298 }
299 
300 LogBook &LogBook::operator<<(void *val)
301 {
302  if( checkLen() )
303  {
304  m_ssText << val;
305  }
306 
307  return *this;
308 }
309 
310 LogBook &LogBook::operator<<(const string &val)
311 {
312  if( checkLen(val.size()) )
313  {
314  m_ssText << val;
315  }
316 
317  return *this;
318 }
319 
320 LogBook &LogBook::operator<<(LogBook& (*pf)(LogBook&))
321 {
322  pf(*this);
323  return *this;
324 }
325 
326 LogBook &LogBook::operator<<(ostream& (*pf)(ostream&))
327 {
328  pf(m_ssText);
329  return *this;
330 }
331 
332 LogBook &LogBook::operator<<(ios& (*pf)(ios&))
333 {
334  pf(m_ssText);
335  return *this;
336 }
337 
338 LogBook &LogBook::operator<<(ios_base& (*pf)(ios_base&))
339 {
340  pf(m_ssText);
341  return *this;
342 }
343 
344 LogBook &LogBook::operator<<(const LogBook &log)
345 {
346  size_t numThis, numSrc;
347  BookCIter iter;
348 
349  numThis = size();
350  numSrc = log.size();
351 
352  // append source entries
353  for(iter = log.m_book.begin(); iter != log.m_book.end(); ++iter)
354  {
355  m_book.push_back(*iter);
356  }
357 
358  m_uTotalEver += numSrc;
359 
360  // limit log's size
361  limitSize();
362 
363  return *this;
364 }
365 
366 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
367 // LogBook Editing, Access, and Utilities
368 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
369 
370 size_t LogBook::logEntry(const string strText, const string strMark)
371 {
372  if( m_uFlags & FlagDebug )
373  {
374  cerr << "DBG: " << __func__ << "("
375  << "mark=\"" << strMark << "\", "
376  << "text=\"" << strText << "\")" <<endl;
377  }
378 
379  Entry entry(strMark, strText);
380 
381  // add log entry to log book
382  m_book.push_back(entry);
383 
384  ++m_uTotalEver;
385 
386  // limit log's size
387  limitSize();
388 
389  return size();
390 }
391 
393 {
394  // no pending entry
395  if( m_ssText.str().empty() )
396  {
397  return size();
398  }
399 
400  if( m_uFlags & FlagDebug )
401  {
402  cerr << "DBG: " << __func__ << "() "
403  << "mark=\"" << m_strMark << "\", "
404  << "text=\"" << m_ssText.str() << "\"" <<endl;
405  }
406 
407  Entry entry(m_strMark, m_ssText.str());
408 
409  // add pending log entry to log book
410  m_book.push_back(entry);
411 
412  // erase pending
413  erasePending();
414 
415  ++m_uTotalEver;
416 
417  // limit log's size
418  limitSize();
419 
420  return size();
421 }
422 
423 void LogBook::setPendingText(const string strText)
424 {
425  ssflush();
426 
427  m_ssText << strText;
428 }
429 
430 void LogBook::setPendingBookMark(const string strMark)
431 {
432  m_strMark = strMark;
433 }
434 
435 void LogBook::setPending(const string strText, const string strMark)
436 {
437  setPendingText(strText);
438  setPendingBookMark(strMark);
439 }
440 
442 {
443  ssflush();
444 }
445 
447 {
448  m_strMark.clear();
449 }
450 
452 {
453  ssflush();
454  m_strMark.clear();
455 }
456 
457 size_t LogBook::eraseToMark(const string strMark, int whence)
458 {
459  BookIter pos;
460 
461  // no bookmark found
462  if( (pos = findMark(strMark)) == m_book.end() )
463  {
464  return size();
465  }
466 
467  switch( whence )
468  {
469  case NEWEST:
470  m_book.erase(pos, m_book.end());
471  break;
472  case OLDEST:
473  m_book.erase(m_book.begin(), pos);
474  break;
475  default:
476  LOGERROR("Unknown whence = %d", whence);
477  break;
478  }
479 
480  return size();
481 }
482 
483 size_t LogBook::eraseEntries(size_t uNumEntries, int whence)
484 {
485  BookIter first, last;
486 
487  if( uNumEntries > size() )
488  {
489  uNumEntries = size();
490  }
491 
492  switch( whence )
493  {
494  case OLDEST:
495  first = m_book.begin();
496  last = first + uNumEntries;
497  m_book.erase(first, last);
498  break;
499  case NEWEST:
500  last = m_book.end();
501  first = last - uNumEntries;
502  m_book.erase(first, last);
503  break;
504  default:
505  LOGERROR("Unknown whence = %d", whence);
506  break;
507  }
508 
509  return size();
510 }
511 
512 void LogBook::resize(size_t uMaxEntries)
513 {
514  if( uMaxEntries > 0 )
515  {
516  m_uMaxEntries = uMaxEntries;
517  limitSize();
518  }
519 }
520 
522 {
523  // logged
524  m_book.clear();
525 
526  // pending
527  erasePending();
528 }
529 
530 const LogBook::Entry &LogBook::at(const string &strMark) const
531 {
532  BookCIter pos;
533 
534  if( (pos = findMark(strMark)) != m_book.end() )
535  {
536  return *pos;
537  }
538  else
539  {
540  return noentry;
541  }
542 }
543 
544 const LogBook::Entry &LogBook::at(const size_t index) const
545 {
546  if( index < size() )
547  {
548  return m_book[index];
549  }
550  else
551  {
552  return noentry;
553  }
554 }
555 
556 const LogBook::Entry &LogBook::at(const size_t index, int whence) const
557 {
558  size_t i;
559 
560  if( index < size() )
561  {
562  i = whence == NEWEST? size() - index - 1: index;
563  return m_book[i];
564  }
565  else
566  {
567  return noentry;
568  }
569 }
570 
571 const LogBook::Entry &LogBook::operator[](const size_t index) const
572 {
573  return at(index);
574 }
575 
576 const LogBook::Entry &LogBook::operator[](const string &strMark) const
577 {
578  return at(strMark);
579 }
580 
582 {
583  if( size() > 0 )
584  {
585  return m_book[size()-1];
586  }
587  else
588  {
589  return noentry;
590  }
591 }
592 
593 
594 size_t LogBook::getBookMarks(BookMarkList &list, int whence) const
595 {
596  switch( whence )
597  {
598  case OLDEST:
599  sortMarks(list);
600  break;
601  case NEWEST:
602  rsortMarks(list);
603  break;
604  default:
605  LOGERROR("Unknown whence = %d", whence);
606  list.clear();
607  }
608 
609  return list.size();
610 }
611 
613 {
614  stringstream ss;
615 
616  ss << "_bookmark." << m_uTotalEver << "_";
617 
618  return ss.str();
619 }
620 
621 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
622 // LogBook Output Stream Manipulators
623 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
624 
625 ostream &rnr::operator<<(ostream &os, const LogBook &log)
626 {
627  return log.printLog(os);
628 }
629 
630 ostream &LogBook::printLog(ostream &os) const
631 {
632  // reverse order: newest to oldest
633  if( m_uFlags & FlagORev )
634  {
635  rprt(os, 0, size() - 1);
636  }
637  // forward order: oldest to newest
638  else
639  {
640  prt(os, 0, size() - 1);
641  }
642 
643  return os;
644 }
645 
646 ostream &LogBook::printToMark(ostream &os, string strMark, int endpt) const
647 {
648  BookCIter pos;
649  size_t indexMark;
650 
651  // no mark
652  if( (pos = findMark(strMark)) == m_book.end() )
653  {
654  return os;
655  }
656 
657  indexMark = distance(m_book.begin(), pos);
658 
659  // reverse order: newest to oldest
660  if( m_uFlags & FlagORev )
661  {
662  if( endpt == OLDEST )
663  {
664  rprt(os, 0, indexMark-1);
665  }
666  else // NEWEST
667  {
668  rprt(os, indexMark, size()-1);
669  }
670  }
671 
672  // forward order: oldest to newest
673  else
674  {
675  if( endpt == OLDEST )
676  {
677  prt(os, 0, indexMark-1);
678  }
679  else // NEWEST
680  {
681  prt(os, indexMark, size()-1);
682  }
683  }
684 
685  return os;
686 }
687 
688 void LogBook::prt(ostream &os, size_t index0, size_t index1) const
689 {
690  BookCIter iter, pos0, pos1;
691  size_t index;
692 
693  if( m_uFlags & FlagDebug )
694  {
695  os << "DBG: " << __func__ << "(" << index0 << ", " << index1 << ")" << endl;
696  }
697 
698  if( size() == 0 )
699  {
700  return;
701  }
702  else if( (index0 > index1) || (index1 >= size()) )
703  {
704  return;
705  }
706 
707  pos0 = m_book.begin() + index0;
708  pos1 = m_book.begin() + index1;
709  index = index0;
710 
711  for(iter = pos0; iter != m_book.end() && iter <= pos1; ++iter)
712  {
713  if( (m_uFlags & FlagOMark) && !iter->m_strMark.empty() )
714  {
715  os << " ~~ " << iter->m_strMark << endl;
716  }
717 
718  if( m_uFlags & FlagONum )
719  {
720  os << setw(3) << index << ". ";
721  }
722 
723  if( m_uFlags & FlagOTime )
724  {
725  os << "[" << iter->m_timestamp << "] ";
726  }
727 
728  os << iter->m_strText << endl;
729 
730  ++index;
731  }
732 }
733 
734 void LogBook::rprt(ostream &os, size_t index0, size_t index1) const
735 {
736  BookCRIter iter, pos0, pos1;
737  size_t last;
738  size_t index;
739 
740  if( m_uFlags & FlagDebug )
741  {
742  os << "DBG: " << __func__ << "(" << index0 << ", " << index1 << ")" << endl;
743  }
744 
745  if( size() == 0 )
746  {
747  return;
748  }
749  else if( (index0 > index1) || (index1 >= size()) )
750  {
751  return;
752  }
753 
754  last = size() - 1;
755 
756  index = index1;
757 
758  pos0 = m_book.rbegin() + last - index1;
759  pos1 = m_book.rbegin() + last - index0;
760 
761  for(iter = pos0; iter != m_book.rend() && iter <= pos1; ++iter)
762  {
763  if( m_uFlags & FlagONum )
764  {
765  os << setw(3) << index << ". ";
766  }
767 
768  if( m_uFlags & FlagOTime )
769  {
770  os << "[" << iter->m_timestamp << "] ";
771  }
772 
773  os << iter->m_strText << endl;
774 
775  if( (m_uFlags & FlagOMark) && !iter->m_strMark.empty() )
776  {
777  os << " ~~ " << iter->m_strMark << endl;
778  }
779 
780  --index;
781  }
782 }
783 
784 
785 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
786 // Support
787 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
788 
790 {
791  if( m_book.size() > m_uMaxEntries )
792  {
794  }
795 }
796 
798 {
799  m_ssText.str(string());
800  m_ssText.clear();
801  m_bWarnThrottle = false;
802 }
803 
804 bool LogBook::checkLen(size_t uEstLen)
805 {
806  if( m_ssText.str().size()+uEstLen < m_uMaxEntryLen )
807  {
808  return true;
809  }
810  else
811  {
812  if( !m_bWarnThrottle )
813  {
814  LOGWARN("Pending entry exceeds max entry length %zu.", m_uMaxEntryLen);
815  m_bWarnThrottle = true;
816  }
817  return false;
818  }
819 }
820 
821 LogBook::BookIter LogBook::findMark(const string &strMark)
822 {
823  BookIter iter;
824 
825  for(iter = m_book.begin(); iter != m_book.end(); ++iter)
826  {
827  if( iter->m_strMark == strMark )
828  {
829  return iter;
830  }
831  }
832 
833  return m_book.end();
834 }
835 
836 LogBook::BookCIter LogBook::findMark(const string &strMark) const
837 {
838  BookCIter iter;
839 
840  for(iter = m_book.begin(); iter != m_book.end(); ++iter)
841  {
842  if( iter->m_strMark == strMark )
843  {
844  return iter;
845  }
846  }
847 
848  return m_book.end();
849 }
850 
851 void LogBook::sortMarks(BookMarkList &sorted) const
852 {
853  BookCIter iter;
854  size_t index;
856 
857  sorted.clear();
858 
859  index = 0;
860 
861  for(iter = m_book.begin(); iter != m_book.end(); ++iter)
862  {
863  if( !iter->m_strMark.empty() )
864  {
865  bookmark.m_strMark = iter->m_strMark;
866  bookmark.m_index = index;
867 
868  if( m_uFlags & FlagDebug )
869  {
870  cerr << "DBG: mark=\"" << bookmark.m_strMark
871  << "\", index=" << bookmark.m_index << endl;
872  }
873 
874  sorted.push_back(bookmark);
875  }
876 
877  ++index;
878  }
879 }
880 
882 {
883  BookCRIter iter;
884  size_t index;
886 
887  sorted.clear();
888 
889  index = size() - 1;
890 
891  for(iter = m_book.rbegin(); iter != m_book.rend(); ++iter)
892  {
893  if( !iter->m_strMark.empty() )
894  {
895  bookmark.m_strMark = iter->m_strMark;
896  bookmark.m_index = index;
897 
898  if( m_uFlags & FlagDebug )
899  {
900  cerr << "DBG: mark=\"" << bookmark.m_strMark
901  << "\", index=" << bookmark.m_index << endl;
902  }
903 
904  sorted.push_back(bookmark);
905  }
906 
907  --index;
908  }
909 }
910 
911 void LogBook::copy(const LogBook &src)
912 {
913  m_strName = src.m_strName;
917  m_uFlags = src.m_uFlags;
918  m_book = src.m_book;
919 }
920 
921 
922 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
923 // LogBook Stream Manipulators
924 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
925 
927 {
928  log.logPending();
929  return log;
930 }
931 
933 {
934  // generate unique name
936  return log;
937 }
938 
939 rnr::lbmanip_bm_ rnr::bookmark(const std::string str)
940 {
941  lbmanip_bm_ o;
942  o.m_strMark = str;
943  return o;
944 }
945 
947 {
949  return log;
950 }
951 
952 rnr::lbmanip_fg_ rnr::setflags(const unsigned flags)
953 {
954  lbmanip_fg_ o;
955  o.m_uFlags = flags;
956  return o;
957 }
958 
960 {
961  log.setFlags(f.m_uFlags);
962  return log;
963 }
unsigned setFlags(const unsigned uFlags)
Set the current formatting flags.
Definition: LogBook.h:630
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...
Definition: LogBook.cxx:646
std::string makeBookMarkLabel()
Generate a unique bookmark label.
Definition: LogBook.cxx:612
size_t eraseEntries(size_t uNumEntries, int whence)
Erases a given number of entries from the log book.
Definition: LogBook.cxx:483
BookDeq m_book
the log book
Definition: LogBook.h:768
std::ostream & printLog(std::ostream &os) const
Print the entire log book to the output stream.
Definition: LogBook.cxx:630
bool isSet(const timespec &a)
Check if timespec is set.
Definition: Time.cxx:105
void erasePending()
Erase the pending log text and associated bookmark.
Definition: LogBook.cxx:451
size_t eraseToMark(const std::string strMark, int whence)
Erases all entries from the log book up to the bookmark.
Definition: LogBook.cxx:457
void ssflush()
Flush the pending text stream.
Definition: LogBook.cxx:797
bool checkLen(size_t uEstLen=1)
Check the length of the pending entry.
Definition: LogBook.cxx:804
static const unsigned FlagDebug
debug
Definition: LogBook.h:103
lbmanip_fg_ setflags(const unsigned flags)
LogBook formatting flags parametric manipulator function.
Definition: LogBook.cxx:952
BookDeq::const_reverse_iterator BookCRIter
const rev book iter
Definition: LogBook.h:755
void limitSize()
Limit size of log book to defined limit.
Definition: LogBook.cxx:789
void clear()
Clear the log book and bookmarks, along with any pending entry.
Definition: LogBook.cxx:521
Time functions and class interfaces.
size_t m_uMaxEntries
maximum number of log entries
Definition: LogBook.h:761
BookDeq::iterator BookIter
book iterator
Definition: LogBook.h:752
static const unsigned FlagONum
output log entry number
Definition: LogBook.h:98
Chronos - God of Time.
Definition: Time.h:63
Log entry structure.
Definition: LogBook.h:108
std::string m_strText
entry text, empty if no text
Definition: LogBook.h:112
size_t getBookMarks(BookMarkList &list, int whence) const
Get a sorted list of bookmark labels.
Definition: LogBook.cxx:594
LogBook(const std::string strName="Log Book", size_t uMaxEntries=MaxEntriesDft, size_t uMaxEntryLen=MaxEntryLenDft)
Default initialization constructor.
Definition: LogBook.cxx:148
std::string m_strMark
bookmark label
Definition: LogBook.h:935
const Entry & lastEntry() const
Get the last (latest) log entry.
Definition: LogBook.cxx:581
Log bookmark structure.
Definition: LogBook.h:167
void rprt(std::ostream &os, size_t index0, size_t index1) const
Reverse print log book from index 1 to index 0, inclusive.
Definition: LogBook.cxx:734
std::string m_strMark
entry bookmark, empty if no mark
Definition: LogBook.h:111
const Entry & at(const std::string &strMark) const
Get the entry at the bookmark.
void setPendingBookMark(const std::string strMark)
Set the pending bookmark.
Definition: LogBook.cxx:430
size_t size() const
Return the number of logged entries in the log book.
Definition: LogBook.h:588
static const unsigned FlagOTime
output log entry time
Definition: LogBook.h:99
void rsortMarks(BookMarkList &sorted) const
Reverse sort bookmarks from newest to oldest.
Definition: LogBook.cxx:881
LogBook class interface.
static const unsigned FlagORev
output log reverse order
Definition: LogBook.h:102
void erasePendingBookMark()
Erase the pending log bookmark.
Definition: LogBook.cxx:446
void setPending(const std::string strText, const std::string strMark)
Set the pending log text and associated bookmark.
Definition: LogBook.cxx:435
LogBook & operator=(const LogBook &rhs)
Assignment operator.
Definition: LogBook.cxx:170
const Entry & operator[](const size_t index) const
Log book array index operator.
Definition: LogBook.cxx:571
static const unsigned FlagOMark
output log entry bookmarks
Definition: LogBook.h:100
LogBook & eoe(LogBook &log)
LogBook end-of-entry stream manipulator.
Definition: LogBook.cxx:926
std::ostream & operator<<(std::ostream &os, const LogBook &log)
Stream insertion operator.
BookIter findMark(const std::string &strMark)
Find position it log book of the bookmarked entry.
BookMark()
Default contructor.
Definition: LogBook.cxx:127
std::stringstream m_ssText
pending text stream
Definition: LogBook.h:767
unsigned m_uFlags
formatting flags
Definition: LogBook.h:764
BookDeq::const_iterator BookCIter
book const iterator
Definition: LogBook.h:753
LogBook parametric formatting flags manipulator structure.
Definition: LogBook.h:969
void copy(const LogBook &src)
Copy log book verbatim to this log book.
Definition: LogBook.cxx:911
LogBook & bookmark(LogBook &log)
LogBook bookmark stream manipulator.
Definition: LogBook.cxx:932
LogBook parametric bookmark stream manipulator structure.
Definition: LogBook.h:933
static const int NEWEST
newest, most recent entries
Definition: LogBook.h:92
void erasePendingText()
Erase the pending log text.
Definition: LogBook.cxx:441
bool empty()
Test if entry is empty ("no entry" entry).
Definition: LogBook.cxx:117
size_t logPending()
Log any pending entry into the log book.
Definition: LogBook.cxx:392
void prt(std::ostream &os, size_t index0, size_t index1) const
Print log book from index 0 to index 1, inclusive.
Definition: LogBook.cxx:688
virtual ~LogBook()
Destructor.
Definition: LogBook.cxx:166
timespec now()
Get the current time, indentified by CLOCK_REALTIME, since the last Epoch.
Definition: Time.cxx:70
std::vector< BookMark > BookMarkList
bookmark list type
Definition: LogBook.h:197
std::string m_strMark
pending bookmark label
Definition: LogBook.h:766
BookMark & operator=(const BookMark &rhs)
Assignment operator.
Definition: LogBook.cxx:137
timespec m_timestamp
entry timestamp
Definition: LogBook.h:110
Entry & operator=(const Entry &rhs)
Assignment operator.
Definition: LogBook.cxx:106
Entry()
Default contructor.
Definition: LogBook.cxx:89
size_t logEntry(const std::string strText, const std::string strMark="")
Log the given entry into the log book.
Definition: LogBook.cxx:370
static const int OLDEST
oldest entries
Definition: LogBook.h:91
void sortMarks(BookMarkList &sorted) const
Sort bookmarks from oldest to newest.
Definition: LogBook.cxx:851
bool m_bWarnThrottle
do [not] throttle warnings
Definition: LogBook.h:765
virtual ~Entry()
Destructor.
Definition: LogBook.cxx:113
std::string m_strName
name of log
Definition: LogBook.h:760
void setPendingText(const std::string strText)
Set the pending log text.
Definition: LogBook.cxx:423
size_t m_uTotalEver
total entries added during lifetime
Definition: LogBook.h:763
void resize(size_t uMaxEntries)
Resize maximum size of log book.
Definition: LogBook.cxx:512
RoadNarrows Robotics.
Definition: Camera.h:74
size_t m_uMaxEntryLen
maximum entry length
Definition: LogBook.h:762