OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librtools/] [RlogFile.hpp] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 wfjm
// $Id: RlogFile.hpp 631 2015-01-09 21:36:51Z mueller $
2 10 wfjm
//
3 29 wfjm
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 wfjm
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 29 wfjm
// 2015-01-08   631   2.2    Open(): now with RerrMsg and cout/cerr support
17 19 wfjm
// 2013-02-23   492   2.1    add Name(), keep log file name; add Dump()
18
// 2013-02-22   491   2.0    add Write(),IsNew(), RlogMsg iface; use lockable
19 12 wfjm
// 2011-04-24   380   1.0.1  use boost::noncopyable (instead of private dcl's)
20 10 wfjm
// 2011-01-30   357   1.0    Initial version
21
// ---------------------------------------------------------------------------
22
 
23
/*!
24
  \file
25 29 wfjm
  \version $Id: RlogFile.hpp 631 2015-01-09 21:36:51Z mueller $
26 10 wfjm
  \brief   Declaration of class RlogFile.
27
*/
28
 
29
#ifndef included_Retro_RlogFile
30
#define included_Retro_RlogFile 1
31
 
32
#include <string>
33
#include <ostream>
34
#include <fstream>
35
 
36 12 wfjm
#include "boost/utility.hpp"
37 19 wfjm
#include "boost/thread/mutex.hpp"
38 12 wfjm
 
39 29 wfjm
#include "RerrMsg.hpp"
40
 
41 10 wfjm
namespace Retro {
42
 
43 19 wfjm
  class RlogMsg;                            // forw decl to avoid circular incl
44
 
45 12 wfjm
  class RlogFile : private boost::noncopyable {
46 10 wfjm
    public:
47
                    RlogFile();
48 19 wfjm
      explicit      RlogFile(std::ostream* os, const std::string& name = "");
49
                   ~RlogFile();
50 10 wfjm
 
51 19 wfjm
      bool          IsNew() const;
52 29 wfjm
      bool          Open(std::string name, RerrMsg& emsg);
53 10 wfjm
      void          Close();
54 19 wfjm
      void          UseStream(std::ostream* os, const std::string& name = "");
55
      const std::string&  Name() const;
56 10 wfjm
 
57 19 wfjm
      void          Write(const std::string& str, char tag = 0);
58 10 wfjm
 
59 19 wfjm
      void          Dump(std::ostream& os, int ind=0, const char* text=0) const;
60
 
61
      // provide boost Lockable interface
62
      void          lock();
63
      void          unlock();
64
 
65
      RlogFile&     operator<<(const RlogMsg& lmsg);
66
 
67 10 wfjm
    protected:
68 19 wfjm
      std::ostream& Stream();
69 10 wfjm
      void          ClearTime();
70 29 wfjm
      std::string   BuildinStreamName(std::ostream* os, const std::string& str);
71 10 wfjm
 
72
    protected:
73
      std::ostream* fpExtStream;            //!< pointer to external stream
74
      std::ofstream fIntStream;             //!< internal stream
75 19 wfjm
      bool          fNew;                   //!< true if never opened or used
76
      std::string   fName;                  //!< log file name
77 10 wfjm
      int           fTagYear;               //!< year of last time tag
78
      int           fTagMonth;              //!< month of last time tag
79
      int           fTagDay;                //!< day of last time tag
80 19 wfjm
      boost::mutex  fMutex;                 //!< mutex to lock file
81 10 wfjm
  };
82
 
83
} // end namespace Retro
84
 
85
#include "RlogFile.ipp"
86
 
87
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.