Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/LogSinkInterface_8h_source.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 22:09:53 2011
Кодировка:

Поисковые слова: quasar
casacore: casa/Logging/LogSinkInterface.h Source File

LogSinkInterface.h

Go to the documentation of this file.
00001 //# LogSinkInterface.h: Accepts LogMessages and posts them to some destination
00002 //# Copyright (C) 1996,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: LogSinkInterface.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00028 
00029 #ifndef CASA_LOGSINKINTERFACE_H
00030 #define CASA_LOGSINKINTERFACE_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Logging/LogFilterInterface.h>
00035 
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary>
00040 //Accepts LogMessages and posts them to some destination
00041 // </summary>
00042 
00043 // <use visibility=local>
00044 
00045 // <reviewed reviewer="wbrouw" date="1996/08/21" tests="tLogging.cc"  demos="dLogging.cc">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> <linkto class=LogMessage>LogMessage</linkto>
00050 //   <li> <linkto class=LogFilterInterface>LogFilterInterface</linkto>
00051 // </prerequisite>
00052 //
00053 // <etymology>
00054 // Log as in "Log Book." Sink from its common usage ("source/sink") as a thing
00055 // which can accept some substance or energy. Interface because this is an
00056 // abstract, not concrete, class.
00057 // </etymology>
00058 //
00059 // <synopsis>
00060 // This abstract base class is not intended for applications programmers. 
00061 // Instead they should look at <linkto class=LogSink>LogSink</linkto>.
00062 //
00063 // This class defines a minimal "posting" interface for all objects which accept
00064 // log messages. The fundamental model of a <src>LogSinkInterface</src> is:
00065 // <ol>
00066 // <li> That it contains a
00067 //      <linkto class=LogFilterInterface>LogFilterInterface</linkto> that is
00068 //      used to accept or reject messages; and
00069 // <li> That it has a post message that takes a log message; and, if it passes
00070 //      the filter, does something with it (prints it to a stream, saves it to
00071 //      a table, ...).
00072 // </ol>
00073 // There is no notion of local vs global sinks - that is imposed by
00074 // <src>LogSink</src>.
00075 // </synopsis>
00076 //
00077 // <example>
00078 // <srcblock>
00079 // LogSinkInterface &ref = ...;
00080 // LogMessage message(...);
00081 // ref.postLocally(message);
00082 // if (ref.filter().lowestPriority() != LogMessage::DEBUGGING) {
00083 //    ref.filter(LogMessage::DEBUGGING);
00084 // }
00085 // </srcblock>
00086 // For a more complete example see <linkto file="Logging.h">Logging.h</linkto>.
00087 // </example>
00088 //
00089 // <motivation>
00090 // Make it straightforward to extend the number of places a message may be
00091 // in the future through derivation.
00092 // </motivation>
00093 //
00094 // <todo asof="1996/07/24">
00095 //   <li> Nothing known.
00096 // </todo>
00097 
00098 
00099 class LogSinkInterface
00100 {
00101 public:
00102   // Create with a <src>NORMAL</src> filter.
00103   LogSinkInterface();
00104   // Create with the supplied <src>filter</src>.
00105   LogSinkInterface(const LogFilterInterface &filter);
00106 
00107   // Copy semantics - copy the filter from <src>other</src> to <src>this</src>
00108   // <group>
00109   LogSinkInterface(const LogSinkInterface &other);
00110   LogSinkInterface &operator=(const LogSinkInterface &);
00111   // </group>
00112 
00113   virtual ~LogSinkInterface();
00114 
00115   // Get/set the filter.
00116   // <group>
00117   virtual const LogFilterInterface &filter() const;
00118   virtual LogSinkInterface &filter(const LogFilterInterface &filter);
00119   // </group>
00120 
00121   // Get number of messages in sink.
00122   virtual uInt nelements() const;
00123 
00124   // Get given part of the i-th message from the sink.
00125   // <group>
00126   virtual Double getTime (uInt i) const;
00127   virtual String getPriority (uInt i) const;
00128   virtual String getMessage (uInt i) const;
00129   virtual String getLocation (uInt i) const;
00130   virtual String getObjectID (uInt i) const;
00131   // </group>
00132 
00133   // This function must be over-ridden in derived classes. If the filter
00134   // passes the message, do what is necessary with the message and return
00135   // <src>True</src>.
00136   virtual Bool postLocally(const LogMessage &message)= 0;
00137 
00138   // Write any pending output.
00139   virtual void flush (Bool global=True);
00140 
00141   // Write a message (usually from another logsink) into the local one.
00142   // The default implementation does nothing.
00143   virtual void writeLocally (Double time, const String& message,
00144                              const String& priority, const String& location,
00145                              const String& objectID);
00146 
00147   // Clear the local sink (i.e. remove all messages from it).
00148   // The default implementation does nothing.
00149   virtual void clearLocally();
00150 
00151   // Returns the id for this class...
00152   static String localId( );
00153   // Returns the id of the LogSink in use...
00154   virtual String id( ) const = 0;
00155   // Write to cerr too
00156   virtual void cerrToo(bool cerr2);
00157   void setTaskName(const String &theTask){taskName=theTask;}
00158 private:
00159   LogFilterInterface* filter_p;
00160 protected:
00161   String taskName;
00162 };
00163 
00164 
00165 
00166 } //# NAMESPACE CASA - END
00167 
00168 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines