# objectregistry.h

Go to the documentation of this file.

    00001 // Module:  Log4CPLUS
    00002 // File:    objectregistry.h
    00003 // Created: 3/2003
    00004 // Author:  Tad E. Smith
    00005 //
    00006 //
    00007 // Copyright (C) Tad E. Smith  All rights reserved.
    00008 //
    00009 // This software is published under the terms of the Apache Software
    00010 // License version 1.1, a copy of which has been included with this
    00011 // distribution in the LICENSE.APL file.
    00012 //
    00013
    00016 #ifndef LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
    00017 #define LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
    00018
    00019 #include <log4cplus/config.h>
    00020 #include <log4cplus/tstring.h>
    00021 #include <log4cplus/helpers/threads.h>
    00022 #include <map>
    00023 #include <memory>
    00024 #include <vector>
    00025
    00026
    00027 namespace log4cplus {
    00028     namespace spi {
    00029
    00034         class LOG4CPLUS_EXPORT ObjectRegistryBase {
    00035         public:
    00036           // public methods
    00041             bool exists(const log4cplus::tstring& name) const;
    00042
    00046             std::vector<log4cplus::tstring> getAllNames() const;
    00047
    00048         protected:
    00049           // Ctor and Dtor
    00050             ObjectRegistryBase();
    00051             virtual ~ObjectRegistryBase();
    00052
    00053           // protected methods
    00058             bool putVal(const log4cplus::tstring& name, void* object);
    00059
    00064             void* getVal(const log4cplus::tstring& name) const;
    00065
    00069             virtual void deleteObject(void *object) const = 0;
    00070
    00074             virtual void clear();
    00075
    00076           // Types
    00077             typedef std::map<log4cplus::tstring, void*> ObjectMap;
    00078
    00079           // Data
    00080             LOG4CPLUS_MUTEX_PTR_DECLARE mutex;
    00081             ObjectMap data;
    00082         };
    00083
    00084     }
    00085 }
    00086
    00087
    00088 #endif // LOG4CPLUS_SPI_OBJECT_REGISTRY_HEADER_
    00089