OSDN Git Service

Copied from unstable
[ultramonkey-l7/sslproxy.git] / parameter / parameter_impl.h
1 /*\r
2  * @file  parameter_impl.h\r
3  * @brief parameter module implementation class.\r
4  *\r
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing\r
6  * Copyright (C) 2008  NTT COMWARE Corporation.\r
7  *\r
8  * This program is free software; you can redistribute it and/or\r
9  * modify it under the terms of the GNU Lesser General Public\r
10  * License as published by the Free Software Foundation; either\r
11  * version 2.1 of the License, or (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
16  * Lesser General Public License for more details.\r
17  *      \r
18  * You should have received a copy of the GNU Lesser General Public\r
19  * License along with this library; if not, write to the Free Software\r
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
21  * 02110-1301 USA\r
22  *\r
23  **********************************************************************/\r
24 \r
25 #ifndef __PARAMETER_IMPL_H__\r
26 #define __PARAMETER_IMPL_H__\r
27 \r
28 #include "parameter_enum.h"\r
29 #include <iostream>\r
30 #include <string>\r
31 #include <map>\r
32 \r
33 \r
34 namespace l7vs\r
35 {\r
36         struct  component{\r
37                 std::string     section;\r
38                 void            (*function)();\r
39                 component(){ section = ""; function = NULL;}\r
40                 component( std::string str, void (*p_func)() ){ section = str; function = p_func;}\r
41                 component& operator=(const component& in_comp){\r
42                         section = in_comp.section;\r
43                         function = in_comp.function;\r
44                         return *this;\r
45                 }\r
46         };\r
47         class ParameterImpl\r
48         {\r
49         private:\r
50                 std::string     removebrank( const std::string& );\r
51                 bool    readParameterFile( const std::string& );\r
52                 bool    isNumeric( const std::string& );\r
53 \r
54                 std::multimap<std::string,std::string>  preparse;\r
55 \r
56                 std::map<PARAMETER_COMPONENT_TAG, component>    compTable;\r
57                 std::multimap<std::string, std::string> stringMap;\r
58                 std::multimap<std::string, int>         intMap;\r
59 \r
60         protected:\r
61                 ParameterImpl();\r
62                 ParameterImpl( const ParameterImpl& );\r
63                 ParameterImpl& operator=( const ParameterImpl& );\r
64 \r
65         public:\r
66                 static ParameterImpl & getInstance(){\r
67                         static ParameterImpl instance;\r
68                         return instance;\r
69                 }\r
70                 bool    init();\r
71                 bool    rereadFile( const PARAMETER_COMPONENT_TAG, const std::string& );\r
72         \r
73                 bool    isIntExist( const PARAMETER_COMPONENT_TAG, const std::string& );\r
74                 bool    isStringExist( const PARAMETER_COMPONENT_TAG, const std::string& );\r
75                 int     getIntValue( const PARAMETER_COMPONENT_TAG, const std::string& );\r
76                 std::string     getStringValue( const PARAMETER_COMPONENT_TAG, const std::string& );\r
77                 void    getStringMapValue( const PARAMETER_COMPONENT_TAG, const std::string&, std::multimap<std::string, std::string>&);\r
78 \r
79                 void    registerFunctionPointer( const PARAMETER_COMPONENT_TAG, void (*)() );\r
80         };\r
81 }\r
82 #endif  //__PARAMETER_IMPL_H__\r