casa  $Rev:20696$
CasapyWatcher.h
Go to the documentation of this file.
00001 //# CasapyWatcher.h: Class to notify children about casapy events.
00002 //# Copyright (C) 2009
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 //# $Id: $
00027 #ifndef CASAPYWATCHER_H_
00028 #define CASAPYWATCHER_H_
00029 
00030 #include <casa/Logging/LogMessage.h>
00031 
00032 #include <vector>
00033 
00034 #include <casa/namespace.h>
00035 using namespace std;
00036 
00037 namespace casac {
00038 
00039 // Parent for any class that wants to be notified about events in casapy.
00040 class CasapyWatcher {
00041     
00042     //# Friend class declarations.
00043     friend class dbus;
00044     friend class logsink;
00045     
00046 public:
00047     // Static //
00048     
00049     // Registers/Unregisters the given watcher.
00050     // <group>
00051     static void registerWatcher(CasapyWatcher* watcher);
00052     static void unregisterWatcher(CasapyWatcher* watcher);
00053     // </group>
00054     
00055     
00056     // Non-Static //
00057     
00058     // Constructor.  Does NOT register watcher (call registerWatcher() to do
00059     // so).
00060     CasapyWatcher();
00061     
00062     // Destructor.  Unregisters watcher.
00063     virtual ~CasapyWatcher();
00064     
00065     
00066     // Called when the log sink location and/or filter priority changes in
00067     // casapy.  Should be overridden if the child class wants to know when this
00068     // happens.
00069     // <group>
00070     virtual void logChanged(const String& sinkLocation);
00071     virtual void logChanged(LogMessage::Priority filterPriority);
00072     // </group>
00073     
00074     // Called when casapy is closing.  Should be overridden if the child class
00075     // wants to know when this happens.
00076     virtual void casapyClosing();
00077     
00078 private:
00079     // Static //
00080 #if 0
00081     // Singleton class that is used to detect when casapy is closing.
00082     class Singleton {
00083     public:
00084         // Constructor.
00085         Singleton() { }
00086         
00087         // Destructor.  Indicates that casapy is closing because there's only
00088         // one static instance of the class.
00089         ~Singleton() { CasapyWatcher::casapyClosing_(); }
00090     };
00091 #endif
00092     // All registered watchers.
00093     static vector<CasapyWatcher*> *WATCHERS;
00094     
00095     // Used to detect when casapy is closing.
00096 /*     static Singleton SINGLETON; */
00097     
00098     
00099     // Called by the logger component when the sink location or filter priority
00100     // changes.
00101     // <group>
00102     static void logChanged_(const String& sinkLocation);
00103     static void logChanged_(LogMessage::Priority filterPriority);
00104     // </group>
00105 
00106     // Called by the dbus component when casapy is closing.
00107     static void casapyClosing_();
00108 };
00109 
00110 }
00111 
00112 #endif /* CASAPYWATCHER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines