22 #include "eclipseclp_config.h" 24 #include <eclipseclass.h> 40 EclExternalConfig::EclExternalConfig() {
41 if (m_instance == NULL) {
50 if (m_instance == NULL) {;
79 {
throw Exception(
"No instance of type EclExternalConfig instantiated"); }
91 {
throw Exception(
"No instance of type Configuration instantiated"); }
110 if (EC_succeed != EC_arg(1).is_string(&path))
112 fprintf(stderr,
"p_get_config_value(): no path given\n");
120 std::vector<bool> vec = config->
get_bools(path);
122 for (std::vector<bool>::reverse_iterator it = vec.rbegin() ; it != vec.rend(); ++it)
123 res = list(EC_word(*it), res);
124 if (EC_succeed != EC_arg(2).unify(res)) {
125 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
131 if (EC_succeed != EC_arg(2).unify(EC_atom((
char*)
"true"))) {
132 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
137 if (EC_succeed != EC_arg(2).unify(EC_atom((
char*)
"false"))) {
138 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
144 else if (config->
is_int(path))
148 std::vector<int> vec = config->
get_ints(path);
150 for (std::vector<int>::reverse_iterator it = vec.rbegin() ; it != vec.rend(); ++it)
151 res = list(EC_word((
long) *it), res);
152 if (EC_succeed != EC_arg(2).unify(res)) {
153 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
158 else if (EC_succeed != EC_arg(2).unify(EC_word((
long) config->
get_int(path)))) {
159 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
164 else if (config->
is_uint(path))
168 std::vector<unsigned int> vec = config->
get_uints(path);
170 for (std::vector<unsigned int>::reverse_iterator it = vec.rend() ; it != vec.rbegin(); --it)
171 res = list(EC_word((
long) *it), res);
172 if (EC_succeed != EC_arg(2).unify(res)) {
173 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
178 else if (EC_succeed != EC_arg(2).unify(EC_word((
long) config->
get_uint(path)))) {
179 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
189 std::vector<float> vec = config->
get_floats(path);
191 for (std::vector<float>::reverse_iterator it = vec.rbegin() ; it != vec.rend(); ++it)
192 res = list(EC_word((
double) *it), res);
193 if (EC_succeed != EC_arg(2).unify(res)) {
194 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
199 if (EC_succeed != EC_arg(2).unify(EC_word((
double) config->
get_float(path)))) {
200 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
209 std::vector<std::string> vec = config->
get_strings(path);
211 for (std::vector<std::string>::reverse_iterator it = vec.rbegin() ; it != vec.rend(); ++it)
212 res = list(EC_word( (*it).c_str()), res);
213 if (EC_succeed != EC_arg(2).unify(res)) {
214 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
219 else if (EC_succeed != EC_arg(2).unify(EC_word(config->
get_string(path).c_str()))) {
220 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
226 fprintf(stderr,
"p_get_config_value(): could not find type of config value! Type: %s\n", config->
get_type(path).c_str() );
Wrapper class for using the config in the implementation of the external predicates.
virtual bool is_string(const char *path)=0
Check if a value is of type string.
static EclExternalConfig * instance()
Get the EclExternalConfig instance.
virtual std::vector< bool > get_bools(const char *path)=0
Get list of values from configuration which is of type bool.
~EclExternalConfig()
Destructor.
virtual std::string get_type(const char *path)=0
Get type of value at given path.
Fawkes library namespace.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual bool is_list(const char *path)=0
Check if a value is a list.
virtual int get_int(const char *path)=0
Get value from configuration which is of type int.
virtual bool is_bool(const char *path)=0
Check if a value is of type bool.
Base class for exceptions in Fawkes.
virtual std::vector< unsigned int > get_uints(const char *path)=0
Get list of values from configuration which is of type unsigned int.
virtual std::vector< float > get_floats(const char *path)=0
Get list of values from configuration which is of type float.
virtual bool is_float(const char *path)=0
Check if a value is of type float.
static void create_initial_object(Configuration *config)
Creates the initial EclExternalConfig object.
virtual bool is_uint(const char *path)=0
Check if a value is of type unsigned int.
virtual std::vector< std::string > get_strings(const char *path)=0
Get list of values from configuration which is of type string.
static Configuration * config_instance()
Access the Configuration instance.
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
virtual bool is_int(const char *path)=0
Check if a value is of type int.
Interface for configuration handling.
virtual float get_float(const char *path)=0
Get value from configuration which is of type float.
virtual std::vector< int > get_ints(const char *path)=0
Get list of values from configuration which is of type int.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.