casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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.
75  MemoryLogSink();
76 
77  // Create an empty sink with the given filter.
78  // <group>
80  explicit MemoryLogSink (const LogFilterInterface& filter);
81  // </group>
82 
83  // Copy constructor (copy semantics).
84  MemoryLogSink (const MemoryLogSink& other);
85 
86  // Assignment (copy semantics).
87  MemoryLogSink& operator= (const MemoryLogSink& other);
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
Abstract base class for filtering LogMessages.
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1537
Block< String > location_p
Block< String > priority_p
Accepts LogMessages and posts them to some destination.
MemoryLogSink()
Create an empty sink without a filter.
virtual uInt nelements() const
Get number of messages in sink.
virtual void clearLocally()
Clear the local sink (i.e.
double Double
Definition: aipstype.h:55
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 resize(uInt nrnew)
Rezize the blocks to the given size, but at least 64 elements more than the current size...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual const LogFilterInterface & filter() const
Get/set the filter.
virtual String getObjectID(uInt i) const
virtual String getLocation(uInt i) const
virtual String getMessage(uInt i) const
virtual Double getTime(uInt i) const
Get given part of the i-th message from the sink.
virtual Bool postLocally(const LogMessage &message)
If the message passes the filter, write it to memory.
static String localId()
Returns the id for this class...
Priority
An &quot;importance&quot; which is assigned to each LogMessage.
Definition: LogMessage.h:105
String id() const
Returns the id of the LogSink in use...
Block< Double > time_p
Save log messages in memory.
Definition: MemoryLogSink.h:71
String: the storage and methods of handling collections of characters.
Definition: String.h:223
MemoryLogSink & operator=(const MemoryLogSink &other)
Assignment (copy semantics).
void copy_other(const MemoryLogSink &other)
Avoid duplicating code in copy ctor and assignment operator.
Informational log messages with with time, priority, and origin.
Definition: LogMessage.h:101
unsigned int uInt
Definition: aipstype.h:51
Block< String > objectID_p
Block< String > message_p
virtual String getPriority(uInt i) const
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42