OSDN Git Service

trunk整理
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / include / parameter.h
1 /*!
2  * @file  parameter.h
3  * @brief ultramonkey-l7 parameter class.
4  *
5  * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6  * Copyright (C) 2009  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 #ifndef PARAMETER_H
25 #define PARAMETER_H
26
27 #include <string>
28 #include <map>
29 #include <vector>
30 #include "parameter_enum.h"
31 #include "error_code.h"
32
33 #ifndef PARAMETER_FILE
34 #define PARAMETER_FILE "/etc/l7vs/l7vs.cf"
35 #endif //PARAMETER_FILE
36
37 namespace l7vs
38 {
39
40
41 //! @class Parameter
42 //! @brief configure file controller
43 //! @brief set key to get value.
44 class Parameter
45 {
46 public:
47         Parameter();                            //!< default constructor
48         ~Parameter();                           //!< default destructor
49
50         //! initialize(file designation)
51         //! @param[in]    component tag
52         //! @param[in]    file name
53         //! @return true success
54         //! @return false fail
55         bool init(const PARAMETER_COMPONENT_TAG, const std::string &);
56
57         //! reload file function
58         //! @param[in]    parameter component tag
59         //! @param[in]    configuration filename
60         //!                   default:PARAMETER_FILE
61         //! @return true  success file read
62         //! @return false failure file read
63         bool read_file(const PARAMETER_COMPONENT_TAG,
64                        const std::string& = PARAMETER_FILE);
65
66         //! parameter int value getter
67         //! @param[in]    parameter category
68         //! @param[in]    parameter key
69         //! @param[out]   error code
70         //! @param[in]    configuration filename
71         //!                   default:PARAMETER_FILE
72         //! @return int value
73         int get_int(const PARAMETER_COMPONENT_TAG,
74                     const std::string &,
75                     error_code &,
76                     const std::string& = PARAMETER_FILE);
77
78         //! parameter string value getter
79         //! @param[in]    parameter category
80         //! @param[in]    parameter key
81         //! @param[out]   error code
82         //! @param[in]    configuration filename
83         //!                   default:PARAMETER_FILE
84         //! @return string value
85         std::string get_string(const PARAMETER_COMPONENT_TAG,
86                                const std::string &,
87                                error_code &,
88                                const std::string& = PARAMETER_FILE);
89
90         //! parameter multistring value getter
91         //! @param[in]    parameter category
92         //! @param[in]    parameter key
93         //! @param[inout] string vector
94         //! @param[out]   error code
95         //! @param[in]    configuration filename
96         //!                   default:PARAMETER_FILE
97         //! @return string value
98         void get_multistring(const PARAMETER_COMPONENT_TAG,
99                              const std::string &,
100                              std::vector<std::string>&,
101                              error_code &,
102                              const std::string& = PARAMETER_FILE);
103 };
104
105 } //namespace l7vs
106
107 #endif //PARAMETER_H