casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_MEMORYLOGSINK_H
27#define CASA_MEMORYLOGSINK_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Logging/LogSinkInterface.h>
32#include <casacore/casa/Containers/Block.h>
33#include <casacore/casa/BasicSL/String.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37//# Forward Declarations
38
39// <summary>
40// Save log messages in memory.
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tLogging.cc" demos="dLogging.cc">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class=LogSinkInterface>LogSinkInterface</linkto>
50// </prerequisite>
51//
52// <synopsis>
53// This class posts messages which pass the filter to
54// memory.
55// </synopsis>
56//
57// <example>
58// See <linkto file="Logging.h">Logging.h</linkto>.
59// </example>
60//
61// <motivation>
62// For temporary images log messages must be held in memory temporarily.
63// </motivation>
64//
65//# <todo asof="2001/06/12">
66//# </todo>
67
69{
70public:
71 // Create an empty sink without a filter.
73
74 // Create an empty sink with the given filter.
75 // <group>
78 // </group>
79
80 // Copy constructor (copy semantics).
82
83 // Assignment (copy semantics).
85
86 virtual ~MemoryLogSink();
87
88 // Get number of messages in sink.
89 virtual uInt nelements() const;
90
91 // Get given part of the i-th message from the sink.
92 // <group>
93 virtual Double getTime (uInt i) const;
94 virtual String getPriority (uInt i) const;
95 virtual String getMessage (uInt i) const;
96 virtual String getLocation (uInt i) const;
97 virtual String getObjectID (uInt i) const;
98 // </group>
99
100 // If the message passes the filter, write it to memory
101 virtual Bool postLocally (const LogMessage& message);
102
103 // Write a message (usually from another logsink) into the local one.
104 virtual void writeLocally (Double time, const String& message,
105 const String& priority, const String& location,
106 const String& objectID);
107
108 // Clear the local sink (i.e. remove all messages from it).
109 virtual void clearLocally();
110
111 // Returns the id for this class...
112 static String localId( );
113 // Returns the id of the LogSink in use...
114 String id( ) const;
115
116private:
117 // Avoid duplicating code in copy ctor and assignment operator
118 void copy_other (const MemoryLogSink& other);
119
120 // Rezize the blocks to the given size, but at least 64 elements
121 // more than the current size.
122 void resize (uInt nrnew);
123
130};
131
132
133
134} //# NAMESPACE CASACORE - END
135
136#endif
simple 1-D array
Definition Block.h:198
Priority
An "importance" which is assigned to each LogMessage.
Definition LogMessage.h:102
virtual const LogFilterInterface & filter() const
Get/set the filter.
MemoryLogSink()
Create an empty sink without a filter.
Block< String > priority_p
virtual uInt nelements() const
Get number of messages in sink.
virtual String getMessage(uInt i) const
virtual String getObjectID(uInt i) const
virtual void clearLocally()
Clear the local sink (i.e.
MemoryLogSink(const LogFilterInterface &filter)
virtual String getLocation(uInt i) const
virtual String getPriority(uInt i) const
static String localId()
Returns the id for this class...
virtual Double getTime(uInt i) const
Get given part of the i-th message from the sink.
Block< String > location_p
MemoryLogSink(LogMessage::Priority filter)
Create an empty sink with the given filter.
Block< String > message_p
Block< String > objectID_p
MemoryLogSink & operator=(const MemoryLogSink &other)
Assignment (copy semantics).
void resize(uInt nrnew)
Rezize the blocks to the given size, but at least 64 elements more than the current size.
MemoryLogSink(const MemoryLogSink &other)
Copy constructor (copy semantics).
String id() const
Returns the id of the LogSink in use...
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.
void copy_other(const MemoryLogSink &other)
Avoid duplicating code in copy ctor and assignment operator.
virtual Bool postLocally(const LogMessage &message)
If the message passes the filter, write it to memory.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
TableExprNode time(const TableExprNode &node)
Definition ExprNode.h:1584
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53