Fawkes API
Fawkes Development Version
|
22 #include "eclipseclp_config.h"
25 #include <eclipseclass.h>
40 EclExternalConfig::EclExternalConfig()
42 if (m_instance == NULL) {
52 if (m_instance == NULL) {
85 throw Exception(
"No instance of type EclExternalConfig instantiated");
98 throw Exception(
"No instance of type Configuration instantiated");
116 if (EC_succeed != EC_arg(1).is_string(&path)) {
117 fprintf(stderr,
"p_get_config_value(): no path given\n");
123 std::vector<bool> vec = config->
get_bools(path);
125 for (std::vector<bool>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
126 res = list(EC_word(*it), res);
127 if (EC_succeed != EC_arg(2).unify(res)) {
128 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
132 }
else if (config->
get_bool(path)) {
133 if (EC_succeed != EC_arg(2).unify(EC_atom((
char *)
"true"))) {
134 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
139 if (EC_succeed != EC_arg(2).unify(EC_atom((
char *)
"false"))) {
140 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
145 }
else if (config->
is_int(path)) {
147 std::vector<int> vec = config->
get_ints(path);
149 for (std::vector<int>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
150 res = list(EC_word((
long)*it), res);
151 if (EC_succeed != EC_arg(2).unify(res)) {
152 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
156 }
else if (EC_succeed != EC_arg(2).unify(EC_word((
long)config->
get_int(path)))) {
157 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
161 }
else if (config->
is_uint(path)) {
163 std::vector<unsigned int> vec = config->
get_uints(path);
165 for (std::vector<unsigned int>::reverse_iterator it = vec.rend(); it != vec.rbegin(); --it)
166 res = list(EC_word((
long)*it), res);
167 if (EC_succeed != EC_arg(2).unify(res)) {
168 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
172 }
else if (EC_succeed != EC_arg(2).unify(EC_word((
long)config->
get_uint(path)))) {
173 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
181 std::vector<float> vec = config->
get_floats(path);
183 for (std::vector<float>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
184 res = list(EC_word((
double)*it), res);
185 if (EC_succeed != EC_arg(2).unify(res)) {
186 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
191 if (EC_succeed != EC_arg(2).unify(EC_word((
double)config->
get_float(path)))) {
192 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
198 std::vector<std::string> vec = config->
get_strings(path);
200 for (std::vector<std::string>::reverse_iterator it = vec.rbegin(); it != vec.rend(); ++it)
201 res = list(EC_word((*it).c_str()), res);
202 if (EC_succeed != EC_arg(2).unify(res)) {
203 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
207 }
else if (EC_succeed != EC_arg(2).unify(EC_word(config->
get_string(path).c_str()))) {
208 fprintf(stderr,
"p_get_config_value(): could not bind return value\n");
214 "p_get_config_value(): could not find type of config value! Type: %s\n",
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_type(const char *path)=0
Get type of value at given path.
~EclExternalConfig()
Destructor.
virtual std::vector< bool > get_bools(const char *path)=0
Get list of values from configuration which is of type bool.
static Configuration * config_instance()
Access the Configuration instance.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual bool is_bool(const char *path)=0
Check if a value is of type bool.
virtual bool is_list(const char *path)=0
Check if a value is a list.
virtual std::vector< unsigned int > get_uints(const char *path)=0
Get list of values from configuration which is of type unsigned int.
virtual int get_int(const char *path)=0
Get value from configuration which is of type int.
Interface for configuration handling.
virtual std::vector< float > get_floats(const char *path)=0
Get list of values from configuration which is of type float.
Fawkes library namespace.
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.
virtual bool is_float(const char *path)=0
Check if a value is of type float.
virtual float get_float(const char *path)=0
Get value from configuration which is of type float.
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
virtual bool is_int(const char *path)=0
Check if a value is of type int.
Wrapper class for using the config in the implementation of the external predicates.
static EclExternalConfig * instance()
Get the EclExternalConfig instance.
static void create_initial_object(Configuration *config)
Creates the initial EclExternalConfig object.
virtual bool is_string(const char *path)=0
Check if a value is of type string.
Base class for exceptions in Fawkes.