OSDN Git Service

corresponded to gcc4.3
[ultramonkey-l7/sslproxy.git] / parameter / parameter.cpp
1 /*
2  * @file  parameter.cpp
3  * @brief parameter module creation class.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2008  NTT COMWARE Corporation.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  **********************************************************************/
24
25 #include "parameter_enum.h"
26 #include "parameter.h"
27 #include "parameter_impl.h"
28 #include "logger_wrapper.h"
29 #include <stdlib.h>
30
31 LOG_CATEGORY_TAG param_cat = LOG_CAT_SSLPROXY_PARAMETER;
32
33 /*!
34  * Constructor of Parameter class
35  */
36 l7vs::Parameter::Parameter()
37 {
38         if( !ParameterImpl::getInstance().init() ){
39                 LOGGER_PUT_LOG_FATAL( param_cat, 1, "Parameter initialize failure" );
40                 /*-------- DEBUG LOG for sslproxy --------*/
41                 if (LOG_LV_DEBUG == logger_get_log_level(param_cat)) {
42                         LOGGER_PUT_LOG_DEBUG(param_cat, 1,
43                                 "function : Constructor l7vs::Parameter::Parameter() : "
44                                 "Initialize error.");
45                 }
46                 /*------ DEBUG LOG END for sslproxy ------*/
47                 exit(1);
48         }
49 }
50
51 /*!
52  * Destructor of Parameter class
53  */
54 l7vs::Parameter::~Parameter()
55 {
56 }
57
58 /*!
59  * reload config file
60  * @param[in]   comp    section TAG
61  * @param[in]   filename    config file name
62  * @return      true = success read file / false = failure read file
63  */
64 bool
65 l7vs::Parameter::rereadFile(PARAMETER_COMPONENT_TAG comp, const std::string& filename)
66 {
67         /*-------- DEBUG LOG for sslproxy --------*/
68         if (LOG_LV_DEBUG == logger_get_log_level(param_cat)) {
69                 LOGGER_PUT_LOG_DEBUG(param_cat, 2,
70                         "function : bool l7vs::Parameter::rereadFile("
71                         "PARAMETER_COMPONENT_TAG comp, "
72                         "const std::string& filename) : "
73                         "Call ParameterImpl.rereadFile("
74                         "comp = %d, "
75                         "filename = %s)",
76                         comp,
77                         filename.c_str());
78         }
79         /*------ DEBUG LOG END for sslproxy ------*/
80         return ParameterImpl::getInstance().rereadFile(comp, filename);
81 }
82
83 /*!
84  * check whether integer data exists.
85  * @param[in]   comp    section TAG
86  * @param[in]   key     key string
87  * @return      true = exist setting value / false = non exist setting value
88  */
89 bool
90 l7vs::Parameter::isIntExist(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
91 {
92         return ParameterImpl::getInstance().isIntExist(comp, key);
93 }
94
95 /*!
96  * check whether character data exists.
97  * @param[in]   comp    section TAG
98  * @param[in]   key     key string
99  * @return      true = exist setting value / false = non exist setting value
100  */
101 bool
102 l7vs::Parameter::isStringExist(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
103 {
104         return ParameterImpl::getInstance().isStringExist(comp, key);
105 }
106
107 /*!
108  * get integer data.
109  * @param[in]   comp    section TAG
110  * @param[in]   key     key string
111  * @return      value
112  */
113 int
114 l7vs::Parameter::getIntValue(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
115 {
116         return ParameterImpl::getInstance().getIntValue(comp, key);
117 }
118
119 /*!
120  * get character data.
121  * @param[in]   comp    section TAG
122  * @param[in]   key     key string
123  * @return      value
124  */
125 std::string
126 l7vs::Parameter::getStringValue(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
127 {
128         return ParameterImpl::getInstance().getStringValue(comp, key);
129 }
130
131 /*!
132  * get character map data.
133  * @param[in]   comp    section TAG
134  * @param[in]   key     key string
135  * @param[out]  retMap  map data
136  * @return      value
137  */
138 void
139 l7vs::Parameter::getStringMapValue(const PARAMETER_COMPONENT_TAG comp, const std::string& key, std::multimap<std::string, std::string>& retMap)
140 {
141         /*-------- DEBUG LOG for sslproxy --------*/
142         if (LOG_LV_DEBUG == logger_get_log_level(param_cat)) {
143                 LOGGER_PUT_LOG_DEBUG(param_cat, 3,
144                         "function : void l7vs::Parameter::getStringMapValue("
145                         "const PARAMETER_COMPONENT_TAG comp, "
146                         "const std::string& key, "
147                         "std::multimap<std::string, std::string>& retMap) : "
148                         "Call ParameterImpl.getStringMapValue("
149                         "comp = %d, "
150                         "key = %s)",
151                         comp,
152                         key.c_str());
153         }
154         /*------ DEBUG LOG END for sslproxy ------*/
155         return ParameterImpl::getInstance().getStringMapValue(comp, key, retMap);
156 }
157
158 /*!
159  * set-parameter function pointer relates component-tag
160  * @param[in]   comp    section TAG
161  * @param[in]   p_func  function pointer
162  */
163 void
164 l7vs::Parameter::registerFunctionPointer(const PARAMETER_COMPONENT_TAG comp, void(*p_func)())
165 {
166         ParameterImpl::getInstance().registerFunctionPointer(comp, p_func);
167 }
168