source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/config/propertysetter.h@ 15

Last change on this file since 15 was 2, checked in by sgosseli, 12 years ago

Add 3rd party libraries (log4cxx).

File size: 4.5 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_CONFIG_PROPERTYSETTER_H
19#define _LOG4CXX_CONFIG_PROPERTYSETTER_H
20
21#include <log4cxx/logstring.h>
22#include <log4cxx/helpers/objectptr.h>
23
24namespace log4cxx
25{
26 namespace helpers
27 {
28 class Object;
29 typedef ObjectPtrT<Object> ObjectPtr;
30
31 class Properties;
32 class Pool;
33 }
34
35 namespace config
36 {
37 /**
38 General purpose Object property setter. Clients repeatedly invokes
39 {@link #setProperty setProperty(name,value)} in order to invoke setters
40 on the Object specified in the constructor.
41
42 <p>Usage:
43 <pre>
44 PropertySetter ps(anObject);
45 ps.set("name", "Joe");
46 ps.set("age", "32");
47 ps.set("isMale", "true");
48 </pre>
49 will cause the invocations anObject->setOption("name", "Joe"),
50 anObject->setOption("age", "32") and anObject->setOption("isMale", "true")
51 if the spi::OptionHandler interface is supported by anObject.
52 */
53 class LOG4CXX_EXPORT PropertySetter
54 {
55 protected:
56 helpers::ObjectPtr obj;
57
58 public:
59 /**
60 Create a new PropertySetter for the specified Object. This is done
61 in prepartion for invoking #setProperty one or more times.
62
63 @param obj the object for which to set properties
64 */
65 PropertySetter(const helpers::ObjectPtr& obj);
66
67 /**
68 Set the properties of an object passed as a parameter in one
69 go. The <code>properties</code> are parsed relative to a
70 <code>prefix</code>.
71
72 @param obj The object to configure.
73 @param properties A java.util.Properties containing keys and values.
74 @param prefix Only keys having the specified prefix will be set.
75 @param p pool to use for any allocations required during call.
76 */
77 static void setProperties(const helpers::ObjectPtr& obj,
78 helpers::Properties& properties,
79 const LogString& prefix,
80 log4cxx::helpers::Pool& p);
81
82 /**
83 Set the properites for the object that match the
84 <code>prefix</code> passed as parameter.
85 */
86 void setProperties(helpers::Properties& properties,
87 const LogString& prefix,
88 log4cxx::helpers::Pool& p);
89
90 /**
91 Set a property on this PropertySetter's Object. If the underlying
92 Object supports the spi::OptionHandler interface, the
93 {@link spi::OptionHandler#setOption setOption} method is called.
94
95 @param option name of the property
96 @param value String value of the property
97 @param p pool to use for any allocations required during call.
98 */
99 void setProperty(const LogString& option,
100 const LogString& value,
101 log4cxx::helpers::Pool& p);
102
103 void activate(log4cxx::helpers::Pool& p);
104 }; // class PropertySetter
105 } // namespace config;
106} // namespace log4cxx
107
108#endif //_LOG4CXX_CONFIG_PROPERTYSETTER_H
Note: See TracBrowser for help on using the repository browser.