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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 wfjm
// $Id: RlogFile.hpp 492 2013-02-24 22:14:47Z mueller $
2 10 wfjm
//
3 19 wfjm
// Copyright 2011-2013 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 19 wfjm
// 2013-02-23   492   2.1    add Name(), keep log file name; add Dump()
17
// 2013-02-22   491   2.0    add Write(),IsNew(), RlogMsg iface; use lockable
18 12 wfjm
// 2011-04-24   380   1.0.1  use boost::noncopyable (instead of private dcl's)
19 10 wfjm
// 2011-01-30   357   1.0    Initial version
20
// ---------------------------------------------------------------------------
21
 
22
/*!
23
  \file
24 19 wfjm
  \version $Id: RlogFile.hpp 492 2013-02-24 22:14:47Z mueller $
25 10 wfjm
  \brief   Declaration of class RlogFile.
26
*/
27
 
28
#ifndef included_Retro_RlogFile
29
#define included_Retro_RlogFile 1
30
 
31
#include <string>
32
#include <ostream>
33
#include <fstream>
34
 
35 12 wfjm
#include "boost/utility.hpp"
36 19 wfjm
#include "boost/thread/mutex.hpp"
37 12 wfjm
 
38 10 wfjm
namespace Retro {
39
 
40 19 wfjm
  class RlogMsg;                            // forw decl to avoid circular incl
41
 
42 12 wfjm
  class RlogFile : private boost::noncopyable {
43 10 wfjm
    public:
44
                    RlogFile();
45 19 wfjm
      explicit      RlogFile(std::ostream* os, const std::string& name = "");
46
                   ~RlogFile();
47 10 wfjm
 
48 19 wfjm
      bool          IsNew() const;
49 10 wfjm
      bool          Open(std::string name);
50
      void          Close();
51 19 wfjm
      void          UseStream(std::ostream* os, const std::string& name = "");
52
      const std::string&  Name() const;
53 10 wfjm
 
54 19 wfjm
      void          Write(const std::string& str, char tag = 0);
55 10 wfjm
 
56 19 wfjm
      void          Dump(std::ostream& os, int ind=0, const char* text=0) const;
57
 
58
      // provide boost Lockable interface
59
      void          lock();
60
      void          unlock();
61
 
62
      RlogFile&     operator<<(const RlogMsg& lmsg);
63
 
64 10 wfjm
    protected:
65 19 wfjm
      std::ostream& Stream();
66 10 wfjm
      void          ClearTime();
67
 
68
    protected:
69
      std::ostream* fpExtStream;            //!< pointer to external stream
70
      std::ofstream fIntStream;             //!< internal stream
71 19 wfjm
      bool          fNew;                   //!< true if never opened or used
72
      std::string   fName;                  //!< log file name
73 10 wfjm
      int           fTagYear;               //!< year of last time tag
74
      int           fTagMonth;              //!< month of last time tag
75
      int           fTagDay;                //!< day of last time tag
76 19 wfjm
      boost::mutex  fMutex;                 //!< mutex to lock file
77 10 wfjm
  };
78
 
79
} // end namespace Retro
80
 
81
#include "RlogFile.ipp"
82
 
83
#endif

powered by: WebSVN 2.1.0

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