source: XMLIO_V2/external/include/Poco/Util/LayeredConfiguration.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 6.2 KB
Line 
1//
2// LayeredConfiguration.h
3//
4// $Id: //poco/1.3/Util/include/Poco/Util/LayeredConfiguration.h#2 $
5//
6// Library: Util
7// Package: Configuration
8// Module:  LayeredConfiguration
9//
10// Definition of the LayeredConfiguration class.
11//
12// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Util_LayeredConfiguration_INCLUDED
40#define Util_LayeredConfiguration_INCLUDED
41
42
43#include "Poco/Util/Util.h"
44#include "Poco/Util/AbstractConfiguration.h"
45#include "Poco/AutoPtr.h"
46#include <list>
47
48
49namespace Poco {
50namespace Util {
51
52
53class Util_API LayeredConfiguration: public AbstractConfiguration
54        /// A LayeredConfiguration consists of a number of AbstractConfigurations.
55        ///
56        /// When reading a configuration property in a LayeredConfiguration,
57        /// all added configurations are searched, in order of their priority.
58        /// Configurations with lower priority values have precedence.
59        ///
60        /// When setting a property, the property is always written to the first writeable
61        /// configuration (see addWriteable()).
62        /// If no writeable configuration has been added to the LayeredConfiguration, and an
63        /// attempt is made to set a property, a RuntimeException is thrown.
64        ///
65        /// Every configuration added to the LayeredConfiguration has a priority value.
66        /// The priority determines the position where the configuration is inserted,
67        /// with lower priority values coming before higher priority values.
68        ///
69        /// If no priority is specified, a priority of 0 is assumed.
70{
71public:
72        LayeredConfiguration();
73                /// Creates the LayeredConfiguration.
74               
75        void add(AbstractConfiguration* pConfig);
76                /// Adds a read-only configuration to the back of the LayeredConfiguration.
77                /// The LayeredConfiguration does not take ownership of the given
78                /// configuration. In other words, the configuration's reference
79                /// count is incremented.
80
81        void add(AbstractConfiguration* pConfig, bool shared);
82                /// Adds a read-only configuration to the back of the LayeredConfiguration.
83                /// If shared is false, the LayeredConfiguration takes ownership
84                /// of the given configuration (and the configuration's reference
85                /// count remains unchanged).
86
87        void add(AbstractConfiguration* pConfig, int priority);
88                /// Adds a read-only configuration to the LayeredConfiguration.
89                /// The LayeredConfiguration does not take ownership of the given
90                /// configuration. In other words, the configuration's reference
91                /// count is incremented.
92
93        void add(AbstractConfiguration* pConfig, int priority, bool shared);
94                /// Adds a read-only configuration the LayeredConfiguration.
95                /// If shared is false, the LayeredConfiguration takes ownership
96                /// of the given configuration (and the configuration's reference
97                /// count remains unchanged).
98
99        void add(AbstractConfiguration* pConfig, int priority, bool writeable, bool shared);
100                /// Adds a configuration to the LayeredConfiguration.
101                /// If shared is false, the LayeredConfiguration takes ownership
102                /// of the given configuration (and the configuration's reference
103                /// count remains unchanged).
104
105        void addWriteable(AbstractConfiguration* pConfig, int priority);
106                /// Adds a writeable configuration to the LayeredConfiguration.
107                /// The LayeredConfiguration does not take ownership of the given
108                /// configuration. In other words, the configuration's reference
109                /// count is incremented.
110
111        void addWriteable(AbstractConfiguration* pConfig, int priority, bool shared);
112                /// Adds a writeable configuration to the LayeredConfiguration.
113                /// If shared is false, the LayeredConfiguration takes ownership
114                /// of the given configuration (and the configuration's reference
115                /// count remains unchanged).
116
117        //@ deprecated
118        void addFront(AbstractConfiguration* pConfig);
119                /// Adds a read-only configuration to the front of the LayeredConfiguration.
120                /// The LayeredConfiguration does not take ownership of the given
121                /// configuration. In other words, the configuration's reference
122                /// count is incremented.
123
124        //@ deprecated
125        void addFront(AbstractConfiguration* pConfig, bool shared);
126                /// Adds a read-only configuration to the front of the LayeredConfiguration.
127                /// If shared is true, the LayeredConfiguration takes ownership
128                /// of the given configuration.
129               
130protected:
131        typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
132       
133        struct ConfigItem
134        {
135                ConfigPtr pConfig;
136                int       priority;
137                bool      writeable;
138        };
139
140        bool getRaw(const std::string& key, std::string& value) const;
141        void setRaw(const std::string& key, const std::string& value);
142        void enumerate(const std::string& key, Keys& range) const;
143       
144        int lowest() const;
145        int highest() const;
146        void insert(const ConfigItem& item);
147       
148        ~LayeredConfiguration();
149
150private:
151        LayeredConfiguration(const LayeredConfiguration&);
152        LayeredConfiguration& operator = (const LayeredConfiguration&);
153
154        typedef std::list<ConfigItem> ConfigList;
155       
156        ConfigList _configs;
157};
158
159
160} } // namespace Poco::Util
161
162
163#endif // Util_LayeredConfiguration_INCLUDED
Note: See TracBrowser for help on using the repository browser.