00001 //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00002 // 00003 // This file is part of E-Cell Simulation Environment package 00004 // 00005 // Copyright (C) 2000-2002 Keio University 00006 // 00007 //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 00008 // 00009 // 00010 // E-Cell is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2 of the License, or (at your option) any later version. 00014 // 00015 // E-Cell is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 // See the GNU General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU General Public 00021 // License along with E-Cell -- see the file COPYING. 00022 // If not, write to the Free Software Foundation, Inc., 00023 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00024 // 00025 //END_HEADER 00026 // 00027 // written by Masayuki Okayama <smash@e-cell.org>, 00028 // E-Cell Project. 00029 // 00030 00031 00032 #if !defined(__LOGGER_BROKER_HPP) 00033 #define __LOGGER_BROKER_HPP 00034 00035 #include <map> 00036 00037 #include "libecs.hpp" 00038 #include "FullID.hpp" 00039 #include "Logger.hpp" 00040 00041 namespace libecs 00042 { 00043 00044 /** @addtogroup logging 00045 *@{ 00046 */ 00047 00048 /** @file */ 00049 00050 /** 00051 LoggerBroker creates and administrates Loggers in a model. 00052 00053 This class creates, holds in a map which associates FullPN with a Logger, 00054 and responds to requests to Loggers. 00055 00056 @see FullPN 00057 @see Logger 00058 00059 */ 00060 00061 class LoggerBroker 00062 { 00063 00064 public: 00065 00066 DECLARE_MAP( const FullPN, LoggerPtr, std::less<const FullPN>, LoggerMap ); 00067 00068 LoggerBroker( ModelRef aModel ); 00069 00070 00071 ~LoggerBroker(); 00072 00073 00074 /** 00075 Get or create a Logger for a PropertySlot. 00076 00077 This method first look for a Logger object which is logging 00078 the specified PropertySlot, and if it is found, returns the 00079 Logger. If there is no Logger connected to the PropertySlot yet, 00080 it creates and returns a new Logger. 00081 00082 FIXME: doc for interval needed 00083 00084 @param aFullPN a FullPN of the requested FullPN 00085 @param anInterval a logging interval 00086 @return a borrowed pointer to the Logger 00087 00088 */ 00089 00090 ECELL_API LoggerPtr getLogger( FullPNCref aFullPN ) const; 00091 00092 ECELL_API LoggerPtr createLogger( FullPNCref aFullPN, PolymorphVectorCref aParamList ); 00093 00094 /** 00095 Flush the data in all the Loggers immediately. 00096 00097 Usually Loggers record data with logging intervals. This method 00098 orders every Logger to write the data immediately ignoring the 00099 logging interval. 00100 00101 */ 00102 00103 void flush(); 00104 00105 00106 /** 00107 Get a const reference to the LoggerMap. 00108 00109 Use this method for const operations such as LoggerMap::size() 00110 and LoggerMap::begin(). 00111 00112 @return a const reference to the LoggerMap. 00113 */ 00114 00115 LoggerMapCref getLoggerMap() const 00116 { 00117 return theLoggerMap; 00118 } 00119 00120 private: 00121 00122 ModelRef getModel() const 00123 { 00124 return theModel; 00125 } 00126 00127 00128 // prevent copy 00129 LoggerBroker( LoggerBrokerCref ); 00130 LoggerBrokerRef operator=( const LoggerBroker& ); 00131 00132 private: 00133 00134 LoggerMap theLoggerMap; 00135 ModelRef theModel; 00136 00137 }; 00138 00139 //@} 00140 00141 } // namespace libecs 00142 00143 #endif 00144 00145 00146