Scopira
20080306
|
#include <loop.h>
Public Member Functions | |
basic_loop (int &argc, char **&argv) | |
~basic_loop () | |
destructor | |
void | list_config (std::vector< std::string > &out) const |
bool | has_config (const std::string &key) const |
const std::string & | get_config (const std::string &key) const |
bool | get_config (const std::string &key, std::string &out) const |
void | set_config (const std::string &key, const std::string &val) |
void | set_config_default (const std::string &key, const std::string &val) |
void | set_config_save (const std::string &key, const std::string &val) |
void | commit_config (void) |
objecttype * | get_root_objecttype (void) |
const std::string & | get_context_name (void) const |
const std::string & | get_config_dir (void) const |
bool | save_object (const std::string &name, scopira::tool::object *o) |
bool | load_object (const std::string &name, scopira::tool::count_ptr< scopira::tool::object > &out) |
Public Member Functions inherited from scopira::tool::object | |
virtual | ~object () |
int | add_ref (void) const |
bool | sub_ref (void) const |
void | auto_ref (void) const |
int | current_ref (void) const |
virtual scopira::tool::oflow_i & | print (scopira::tool::oflow_i &o) const |
virtual bool | load (scopira::tool::iobjflow_i &in) |
virtual void | save (scopira::tool::oobjflow_i &out) const |
bool | is_alive_object (void) const |
bool | is_dead_object (void) const |
Static Public Member Functions | |
static basic_loop * | instance (void) |
returns the static instance | |
static std::string | config_expand (const std::string &s) |
Additional Inherited Members | |
Protected Member Functions inherited from scopira::tool::object | |
object (void) | |
object (bool neverusecounter) | |
A basic, non-gui mainloop. This does objloader and OUTPUT stream preparation, aswell as config parameter parsing.
Build in options, so far: debug=1 show some debug information on startup noui=1 disable any gui (only lab_loop looks at this) config=filename sepecifies a text based config file to parse (standard key=value format, just like the command line) noconsole=1 closes the terminal on win32, ignored option on other platforms lib=filename.so loads a dynamic library, explictly libdir=directory process all the .so files in the given directory with _lib
These arent implemented, but are possibilities.... configdir=dir override whole config dir?
scopira::core::basic_loop::basic_loop | ( | int & | argc, |
char **& | argv | ||
) |
Basic constructor.
void scopira::core::basic_loop::commit_config | ( | void | ) |
Commit all the flags that have been marked for saving to disk now. This is also called by lab_loop's destructor.
If none have been marked, this will do nothing (not even create an empty file).
|
static |
Returns a string that has been "expanded", useful for various configuration settings. For example, ~ will be expanded to the users home directory, and $ENV style environmental variables will be expanded.
const std::string& scopira::core::basic_loop::get_config | ( | const std::string & | key | ) | const |
Get the vlaue of the given configutation flag. Empty string will be returned if it's not set.
bool scopira::core::basic_loop::get_config | ( | const std::string & | key, |
std::string & | out | ||
) | const |
Gets the configutation value of the given key and put it into out. If there is no value for the given key, out is untouched and false is returned. Non name-valued parameters (like lone files names and the program name itself will be stored in the keys param, param+, param++, param+++, etc. The program nameitself is usually param, so you'll want to start with param+.
|
inline |
Returns the location of all the configuration files.
|
inline |
Gets the context name. This is the name of the application, calculated as arv[0] sans path and extension.
objecttype* scopira::core::basic_loop::get_root_objecttype | ( | void | ) |
Get the root objecttype in the type-information-tree.
bool scopira::core::basic_loop::has_config | ( | const std::string & | key | ) | const |
Does the configutation system have the given key set?
void scopira::core::basic_loop::list_config | ( | std::vector< std::string > & | out | ) | const |
Enumerates all the current config keys to the given output string vector.
bool scopira::core::basic_loop::load_object | ( | const std::string & | name, |
scopira::tool::count_ptr< scopira::tool::object > & | out | ||
) |
Reads an object from disk into the given out ptr. Returns true on success. Note that this function may return true and set out to null, if the given object saved to disk was infact a null object.
bool scopira::core::basic_loop::save_object | ( | const std::string & | name, |
scopira::tool::object * | o | ||
) |
Saves the given object to disk. name cannot be "". The object may be null.
Returns true on success (although, if it fails, I'm not how you'd want to handle it)
void scopira::core::basic_loop::set_config | ( | const std::string & | key, |
const std::string & | val | ||
) |
Sets the value of the given configurations flag.
void scopira::core::basic_loop::set_config_default | ( | const std::string & | key, |
const std::string & | val | ||
) |
Sets the value of the given configurations flag, but only if it was unset previously.
void scopira::core::basic_loop::set_config_save | ( | const std::string & | key, |
const std::string & | val | ||
) |
Sets the value of the given configurations flag and mark the item for saving to disk (and thus reloading next time) for the next commit_config().