00001 // Module: Log4CPLUS 00002 // File: objectregistry.h 00003 // Created: 3/2003 00004 // Author: Tad E. Smith 00005 // 00006 // 00007 // Copyright 2003-2009 Tad E. Smith 00008 // 00009 // Licensed under the Apache License, Version 2.0 (the "License"); 00010 // you may not use this file except in compliance with the License. 00011 // You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, software 00016 // distributed under the License is distributed on an "AS IS" BASIS, 00017 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 // See the License for the specific language governing permissions and 00019 // limitations under the License. 00020 00023 #ifndef LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 00024 #define LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 00025 00026 #include "dcmtk/oflog/config.h" 00027 #include "dcmtk/oflog/tstring.h" 00028 #include "dcmtk/oflog/helpers/threads.h" 00029 #include "dcmtk/ofstd/oflist.h" 00030 #include "dcmtk/ofstd/ofmap.h" 00031 //#include <map> 00032 //#include <memory> 00033 //#include <vector> 00034 00035 00036 namespace log4cplus { 00037 namespace spi { 00038 00043 class LOG4CPLUS_EXPORT ObjectRegistryBase { 00044 public: 00045 // public methods 00050 bool exists(const log4cplus::tstring& name) const; 00051 00055 OFList<log4cplus::tstring> getAllNames() const; 00056 00057 protected: 00058 // Ctor and Dtor 00059 ObjectRegistryBase(); 00060 virtual ~ObjectRegistryBase(); 00061 00062 // protected methods 00067 bool putVal(const log4cplus::tstring& name, void* object); 00068 00073 void* getVal(const log4cplus::tstring& name) const; 00074 00078 virtual void deleteObject(void *object) const = 0; 00079 00083 virtual void clear(); 00084 00085 // Types 00086 typedef OFMap<log4cplus::tstring, void*> ObjectMap; 00087 00088 // Data 00089 LOG4CPLUS_MUTEX_PTR_DECLARE mutex; 00090 ObjectMap data; 00091 }; 00092 00093 } 00094 } 00095 00096 00097 #endif // LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_ 00098