casacore
MemoryLogSink.h
Go to the documentation of this file.
1 //# MemoryLogSink.h: Save log messages in memory
2 //# Copyright (C) 2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef CASA_MEMORYLOGSINK_H
30 #define CASA_MEMORYLOGSINK_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Logging/LogSinkInterface.h>
35 #include <casacore/casa/Containers/Block.h>
36 #include <casacore/casa/BasicSL/String.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 
42 // <summary>
43 // Save log messages in memory.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLogging.cc" demos="dLogging.cc">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class=LogSinkInterface>LogSinkInterface</linkto>
53 // </prerequisite>
54 //
55 // <synopsis>
56 // This class posts messages which pass the filter to
57 // memory.
58 // </synopsis>
59 //
60 // <example>
61 // See <linkto file="Logging.h">Logging.h</linkto>.
62 // </example>
63 //
64 // <motivation>
65 // For temporary images log messages must be held in memory temporarily.
66 // </motivation>
67 //
68 //# <todo asof="2001/06/12">
69 //# </todo>
70 
72 {
73 public:
74  // Create an empty sink without a filter.
76 
77  // Create an empty sink with the given filter.
78  // <group>
81  // </group>
82 
83  // Copy constructor (copy semantics).
84  MemoryLogSink (const MemoryLogSink& other);
85 
86  // Assignment (copy semantics).
88 
89  virtual ~MemoryLogSink();
90 
91  // Get number of messages in sink.
92  virtual uInt nelements() const;
93 
94  // Get given part of the i-th message from the sink.
95  // <group>
96  virtual Double getTime (uInt i) const;
97  virtual String getPriority (uInt i) const;
98  virtual String getMessage (uInt i) const;
99  virtual String getLocation (uInt i) const;
100  virtual String getObjectID (uInt i) const;
101  // </group>
102 
103  // If the message passes the filter, write it to memory
104  virtual Bool postLocally (const LogMessage& message);
105 
106  // Write a message (usually from another logsink) into the local one.
107  virtual void writeLocally (Double time, const String& message,
108  const String& priority, const String& location,
109  const String& objectID);
110 
111  // Clear the local sink (i.e. remove all messages from it).
112  virtual void clearLocally();
113 
114  // Returns the id for this class...
115  static String localId( );
116  // Returns the id of the LogSink in use...
117  String id( ) const;
118 
119 private:
120  // Avoid duplicating code in copy ctor and assignment operator
121  void copy_other (const MemoryLogSink& other);
122 
123  // Rezize the blocks to the given size, but at least 64 elements
124  // more than the current size.
125  void resize (uInt nrnew);
126 
133 };
134 
135 
136 
137 } //# NAMESPACE CASACORE - END
138 
139 #endif
casacore::MemoryLogSink::location_p
Block< String > location_p
Definition: MemoryLogSink.h:131
casacore::MemoryLogSink::objectID_p
Block< String > objectID_p
Definition: MemoryLogSink.h:132
casacore::MemoryLogSink::nelements
virtual uInt nelements() const
Get number of messages in sink.
casacore::LogMessage::Priority
Priority
An "importance" which is assigned to each LogMessage.
Definition: LogMessage.h:105
casacore::MemoryLogSink::localId
static String localId()
Returns the id for this class...
casacore::MemoryLogSink::postLocally
virtual Bool postLocally(const LogMessage &message)
If the message passes the filter, write it to memory.
casacore::MemoryLogSink::~MemoryLogSink
virtual ~MemoryLogSink()
casacore::MemoryLogSink::MemoryLogSink
MemoryLogSink()
Create an empty sink without a filter.
casacore::LogFilterInterface
Abstract base class for filtering LogMessages.
Definition: LogFilterInterface.h:85
casacore::MemoryLogSink::getPriority
virtual String getPriority(uInt i) const
casacore::MemoryLogSink::copy_other
void copy_other(const MemoryLogSink &other)
Avoid duplicating code in copy ctor and assignment operator.
casacore::MemoryLogSink::getTime
virtual Double getTime(uInt i) const
Get given part of the i-th message from the sink.
casacore::Double
double Double
Definition: aipstype.h:55
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::LogMessage
Informational log messages with with time, priority, and origin.
Definition: LogMessage.h:101
casacore::MemoryLogSink::MemoryLogSink
MemoryLogSink(const MemoryLogSink &other)
Copy constructor (copy semantics).
casacore::MemoryLogSink::operator=
MemoryLogSink & operator=(const MemoryLogSink &other)
Assignment (copy semantics).
casacore::MemoryLogSink::getMessage
virtual String getMessage(uInt i) const
casacore::MemoryLogSink::getLocation
virtual String getLocation(uInt i) const
casacore::MemoryLogSink::getObjectID
virtual String getObjectID(uInt i) const
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::MemoryLogSink::writeLocally
virtual void writeLocally(Double time, const String &message, const String &priority, const String &location, const String &objectID)
Write a message (usually from another logsink) into the local one.
casacore::MemoryLogSink::priority_p
Block< String > priority_p
Definition: MemoryLogSink.h:129
casacore::MemoryLogSink
Save log messages in memory.
Definition: MemoryLogSink.h:72
casacore::time
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1537
casacore::MemoryLogSink::message_p
Block< String > message_p
Definition: MemoryLogSink.h:130
casacore::MemoryLogSink::nmsg_p
uInt nmsg_p
Definition: MemoryLogSink.h:127
casacore::MemoryLogSink::clearLocally
virtual void clearLocally()
Clear the local sink (i.e.
casacore::MemoryLogSink::MemoryLogSink
MemoryLogSink(const LogFilterInterface &filter)
casacore::LogSinkInterface
Accepts LogMessages and posts them to some destination.
Definition: LogSinkInterface.h:100
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::MemoryLogSink::id
String id() const
Returns the id of the LogSink in use...
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Block< Double >
casacore::MemoryLogSink::resize
void resize(uInt nrnew)
Rezize the blocks to the given size, but at least 64 elements more than the current size.
casacore::LogSinkInterface::filter
virtual const LogFilterInterface & filter() const
Get/set the filter.
casacore::MemoryLogSink::MemoryLogSink
MemoryLogSink(LogMessage::Priority filter)
Create an empty sink with the given filter.
casacore::MemoryLogSink::time_p
Block< Double > time_p
Definition: MemoryLogSink.h:128