OSDN Git Service

4f87f258fd94e3d957c6477edf7c95cd296ac51f
[ultramonkey-l7/ultramonkey-l7-v2.git] / parameter / parameter.cpp
1 #include "parameter_enum.h"
2 #include "parameter.h"
3 #include "parameter_impl.h"
4 #include "logger_wrapper.h"
5
6 #if !defined(LOGGER_PROCESS_VSD) && !defined(LOGGER_PROCESS_ADM) && !defined(LOGGER_PROCESS_SNM)
7 #define LOGGER_PROCESS_VSD
8 #endif
9
10 #ifdef  LOGGER_PROCESS_SNM
11 LOG_CATEGORY_TAG param_cat = LOG_CAT_SNMPAGENT_PARAMETER;
12 #elif   LOGGER_PROCESS_ADM
13 LOG_CATEGORY_TAG param_cat = LOG_CAT_L7VSADM_PARAMETER;
14 #else
15 LOG_CATEGORY_TAG param_cat = LOG_CAT_L7VSD_PARAMETER;
16 #endif
17
18 /*!
19  * Constructor of Parameter class
20  */
21 l7vs::Parameter::Parameter()
22 {
23         if( !ParameterImpl::getInstance().init() ){
24                 LOGGER_PUT_LOG_FATAL( param_cat, 1, "Parameter initialize failure" );
25                 switch( param_cat ){
26                 case LOG_CAT_L7VSADM_PARAMETER:
27                         break;
28                 default:
29 //                      throw 1;        //don't throw exception at singleton constructor...
30                         exit(1);
31                 }
32         }
33 }
34
35 /*!
36  * Destructor of Parameter class
37  */
38 l7vs::Parameter::~Parameter()
39 {
40 }
41
42 /*!
43  * reload config file
44  * @param[in]   comp    section TAG
45  * @return      true = success read file / false = failure read file
46  */
47 bool
48 l7vs::Parameter::rereadFile(PARAMETER_COMPONENT_TAG comp)
49 {
50         return ParameterImpl::getInstance().rereadFile(comp);
51 }
52
53 /*!
54  * check whether integer data exists.
55  * @param[in]   comp    section TAG
56  * @param[in]   key     key string
57  * @return      true = exist setting value / false = non exist setting value
58  */
59 bool
60 l7vs::Parameter::isIntExist(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
61 {
62         return ParameterImpl::getInstance().isIntExist(comp, key);
63 }
64
65 /*!
66  * check whether character data exists.
67  * @param[in]   comp    section TAG
68  * @param[in]   key     key string
69  * @return      true = exist setting value / false = non exist setting value
70  */
71 bool
72 l7vs::Parameter::isStringExist(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
73 {
74         return ParameterImpl::getInstance().isStringExist(comp, key);
75 }
76
77 /*!
78  * get integer data.
79  * @param[in]   comp    section TAG
80  * @param[in]   key     key string
81  * @return      value
82  */
83 int
84 l7vs::Parameter::getIntValue(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
85 {
86         return ParameterImpl::getInstance().getIntValue(comp, key);
87 }
88
89 /*!
90  * get character data.
91  * @param[in]   comp    section TAG
92  * @param[in]   key     key string
93  * @return      value
94  */
95 std::string
96 l7vs::Parameter::getStringValue(const PARAMETER_COMPONENT_TAG comp, const std::string& key)
97 {
98         return ParameterImpl::getInstance().getStringValue(comp, key);
99 }
100
101 /*!
102  * set-parameter function pointer relates component-tag
103  * @param[in]   comp    section TAG
104  * @param[in]   p_func  function pointer
105  */
106 void
107 l7vs::Parameter::registerFunctionPointer(const PARAMETER_COMPONENT_TAG comp, void(*p_func)())
108 {
109         ParameterImpl::getInstance().registerFunctionPointer(comp, p_func);
110 }
111