Scopira  20080306
scopira::core::basic_loop Class Reference

#include <loop.h>

Inheritance diagram for scopira::core::basic_loop:

Public Member Functions

 basic_loop (int &argc, char **&argv)
 ~basic_loop ()
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)
objecttypeget_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_iprint (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_loopinstance (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)

Detailed Description

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 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?

Aleksander Demko

Constructor & Destructor Documentation

◆ basic_loop()

scopira::core::basic_loop::basic_loop ( int &  argc,
char **&  argv 

Basic constructor.

Aleksander Demko

Member Function Documentation

◆ commit_config()

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).

Aleksander Demko

◆ config_expand()

static std::string scopira::core::basic_loop::config_expand ( const std::string &  s)

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.

Aleksander Demko

◆ get_config() [1/2]

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.

Aleksander Demko

◆ get_config() [2/2]

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+.

Aleksander Demko

◆ get_config_dir()

const std::string& scopira::core::basic_loop::get_config_dir ( void  ) const

Returns the location of all the configuration files.

Aleksander Demko

◆ get_context_name()

const std::string& scopira::core::basic_loop::get_context_name ( void  ) const

Gets the context name. This is the name of the application, calculated as arv[0] sans path and extension.

Aleksander Demko

◆ get_root_objecttype()

objecttype* scopira::core::basic_loop::get_root_objecttype ( void  )

Get the root objecttype in the type-information-tree.

Aleksander Demko

◆ has_config()

bool scopira::core::basic_loop::has_config ( const std::string &  key) const

Does the configutation system have the given key set?

Aleksander Demko

◆ list_config()

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.

Aleksander Demko

◆ load_object()

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.

Aleksander Demko

◆ save_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)

Aleksander Demko

◆ set_config()

void scopira::core::basic_loop::set_config ( const std::string &  key,
const std::string &  val 

Sets the value of the given configurations flag.

Aleksander Demko

◆ set_config_default()

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.

Aleksander Demko

◆ set_config_save()

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().

Aleksander Demko

The documentation for this class was generated from the following file: