3 ==================================================================================
4 Copyright (c) 2020 AT&T Intellectual Property.
5 Copyright (c) 2020 Nokia
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
23 Abstract: Header for the config reader/watcher class.
26 Author: E. Scott Daniels
29 #ifndef XAPP_CONFIG_HPP
30 #define XAPP_CONFIG_HPP
38 #include "config_cb.hpp"
42 #define MAX_PFNAME (4096 + 256) // max path name and max filname + nil for buffer allocation
45 std::string fname = ""; // the file name that we'll listen to
46 std::thread* listener = NULL; // listener thread info
48 std::shared_ptr<Jhash> jh = NULL; // the currently parsed json from the config
49 std::unique_ptr<Config_cb> cb = NULL; // info needed to drive user code when config change noticed
50 void* user_cb_data = NULL; // data that the caller wants passed on notification callback
52 // -----------------------------------------------------------------------
54 std::shared_ptr<xapp::Jhash> jparse( std::string fname );
55 std::shared_ptr<xapp::Jhash> jparse( );
60 Config( const std::string& fname);
62 bool Get_control_bool( const std::string& name, bool defval ) const;
63 bool Get_control_bool( const std::string& name ) const;
65 std::string Get_contents( ) const;
67 std::string Get_control_str( const std::string& name, const std::string& defval ) const;
68 std::string Get_control_str( const std::string& name ) const;
70 double Get_control_value( const std::string& name, double defval ) const;
71 double Get_control_value( const std::string& name ) const;
73 std::string Get_port( const std::string& name ) const;
75 void Set_callback( notify_callback usr_func, void* usr_data );