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

Subversion Repositories w11

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 wfjm
// $Id: RlogFile.cpp 365 2011-02-28 07:28:26Z mueller $
2
//
3
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
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
// 2011-01-30   357   1.0    Initial version
17
// ---------------------------------------------------------------------------
18
 
19
/*!
20
  \file
21
  \version $Id: RlogFile.cpp 365 2011-02-28 07:28:26Z mueller $
22
  \brief   Implemenation of RlogFile.
23
*/
24
 
25
#include <sys/time.h>
26
 
27
#include "RlogFile.hpp"
28
#include "RosPrintf.hpp"
29
 
30
using namespace std;
31
using namespace Retro;
32
 
33
/*!
34
  \class Retro::RlogFile
35
  \brief FIXME_docs
36
*/
37
 
38
//------------------------------------------+-----------------------------------
39
//! Default constructor
40
 
41
RlogFile::RlogFile()
42
  : fpExtStream(0),
43
    fIntStream()
44
{
45
  ClearTime();
46
}
47
 
48
//------------------------------------------+-----------------------------------
49
//! FIXME_docs
50
 
51
RlogFile::RlogFile(std::ostream* os)
52
  : fpExtStream(os),
53
    fIntStream()
54
{}
55
 
56
//------------------------------------------+-----------------------------------
57
//! Destructor
58
 
59
RlogFile::~RlogFile()
60
{}
61
 
62
//------------------------------------------+-----------------------------------
63
//! FIXME_docs
64
 
65
bool RlogFile::Open(std::string name)
66
{
67
  fpExtStream = 0;
68
  fIntStream.open(name.c_str());
69
  return fIntStream.is_open();
70
}
71
 
72
//------------------------------------------+-----------------------------------
73
//! FIXME_docs
74
 
75
void RlogFile::Close()
76
{
77
  fIntStream.close();
78
  return;
79
}
80
 
81
//------------------------------------------+-----------------------------------
82
//! FIXME_docs
83
 
84
void RlogFile::UseStream(std::ostream* os)
85
{
86
  if (fIntStream.is_open()) Close();
87
  fpExtStream = os;
88
  return;
89
}
90
 
91
//------------------------------------------+-----------------------------------
92
//! FIXME_docs
93
 
94
std::ostream& RlogFile::operator()(char c)
95
{
96
  struct timeval tval;
97
  gettimeofday(&tval, 0);
98
 
99
  struct tm tymd;
100
  localtime_r(&tval.tv_sec, &tymd);
101
 
102
  ostream& os = operator()();
103
 
104
  if (tymd.tm_year != fTagYear  ||
105
      tymd.tm_mon  != fTagMonth ||
106
      tymd.tm_mday != fTagDay) {
107
 
108
    os << "-+- "
109
       << RosPrintf(tymd.tm_year+1900,"d",4) << "-"
110
       << RosPrintf(tymd.tm_mon,"d0",2) << "-"
111
       << RosPrintf(tymd.tm_mday,"d0",2) << " -+- \n";
112
 
113
    fTagYear  = tymd.tm_year;
114
    fTagMonth = tymd.tm_mon;
115
    fTagDay   = tymd.tm_mday;
116
  }
117
 
118
  int usec = (int)(tval.tv_usec/1000);
119
 
120
  os << "-" << c << "- "
121
     << RosPrintf(tymd.tm_hour,"d0",2) << ":"
122
     << RosPrintf(tymd.tm_min,"d0",2) << ":"
123
     << RosPrintf(tymd.tm_sec,"d0",2) << "."
124
     << RosPrintf(usec,"d0",3) << " : ";
125
 
126
  return os;
127
}
128
 
129
//------------------------------------------+-----------------------------------
130
//! FIXME_docs
131
 
132
void RlogFile::ClearTime()
133
{
134
  fTagYear  = -1;
135
  fTagMonth = -1;
136
  fTagDay   = -1;
137
  return;
138
}
139
 
140
//------------------------------------------+-----------------------------------
141
#if (defined(Retro_NoInline) || defined(Retro_RlogFile_NoInline))
142
#define inline
143
#include "RlogFile.ipp"
144
#undef  inline
145
#endif

powered by: WebSVN 2.1.0

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