ContRap-Core
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

crp::Options Class Reference

Class Options implements a singleton options container. More...

#include <options.h>

Inheritance diagram for crp::Options:
crp::XMLDataPool crp::XMLParser

Public Member Functions

virtual ~Options ()
 Cleans up memory.
void update_cache ()
 Updates the cache information.
const std::vector< std::string > & get_search_paths () const
 Returns the search paths were ContRap looks for plugins.
const std::vector< std::string > & get_template_paths () const
 Returns the search paths were ContRap looks for templates.
const std::string & get_install_path ()
 Returns the installation path of ContRap.
void add_template_path (const std::string &path)
 Adds a template path manually.
void set_arguments (int argc, char **argv)
 Sets the command line arguments.
int & get_argc ()
 Returns the command line arguments count given by the application.
char ** get_argv ()
 Returns the values of the command line arguments.
std::string find_file (const std::string &file_name)
 Returns the full path to a file with the given name within the range of paths interesting for ContRap.
std::string find_icon (const std::string &file_name)
 Returns the full path to an icon with the given name within the range of paths interesting for ContRap.
std::string find_template (const std::string &path)
 Returns the full path to a template with the given name within the range of paths interesting for ContRap.
void set_worksheet (bool status)
 Sets the worksheet mode.
bool is_worksheet ()
 Returns true if the core library was initialized in worksheet mode.

Static Public Member Functions

static Optionsget_instance ()
 Returns the singleton instance of the class.

Protected Member Functions

void update ()
 Updates the options.
void create_options ()
 Creates a new options file.
std::string find_file_rec (const std::string &path, const std::string &file_name)
 Recursive file finder.
std::string find_template_rec (const std::string &path, const std::string &file_name)
 Recursive template searcher.

Protected Attributes

std::vector< std::string > search_paths
 Search paths.
std::vector< std::string > template_paths
 Template paths.
std::vector< std::string > icon_paths
 Icon search paths.
std::map< std::string,
std::string > 
icon_cache
 Icon cache.
int argc
 Command line arguments.
char ** argv
bool worksheet
 Worksheet mode.
std::string install_path
 Install path of contrap.

Static Protected Attributes

static Optionsoptions
 Options instance.

Detailed Description

Class Options implements a singleton options container.


Constructor & Destructor Documentation

virtual crp::Options::~Options ( ) [virtual]

Cleans up memory.


Member Function Documentation

void crp::Options::add_template_path ( const std::string &  path)

Adds a template path manually.

Parameters:
pathNew template search path
void crp::Options::create_options ( ) [protected]

Creates a new options file.

std::string crp::Options::find_file ( const std::string &  file_name)

Returns the full path to a file with the given name within the range of paths interesting for ContRap.

This method recursively searches several paths to locate the file. The first searched path is the path to the application start folder. The other paths are given by the options.

ContRap does not follow symbolic links when searching for files.

Parameters:
file_nameFile name
Returns:
Full path or an empty string if no file found
std::string crp::Options::find_file_rec ( const std::string &  path,
const std::string &  file_name 
) [protected]

Recursive file finder.

std::string crp::Options::find_icon ( const std::string &  file_name)

Returns the full path to an icon with the given name within the range of paths interesting for ContRap.

This only searches within the icon installation paths of registered libraries.

Parameters:
file_nameFile name.
Returns:
Full path or an empty string if no file found.
std::string crp::Options::find_template ( const std::string &  path)

Returns the full path to a template with the given name within the range of paths interesting for ContRap.

This only searches within the icon installation paths of registered libraries.

Parameters:
pathRelative file name or a full path.
Returns:
Full path or an empty string if no file found.
std::string crp::Options::find_template_rec ( const std::string &  path,
const std::string &  file_name 
) [protected]

Recursive template searcher.

int& crp::Options::get_argc ( ) [inline]

Returns the command line arguments count given by the application.

Returns:
Arguments count
char** crp::Options::get_argv ( ) [inline]

Returns the values of the command line arguments.

Returns:
Command line arguments
const std::string& crp::Options::get_install_path ( )

Returns the installation path of ContRap.

The path is given by a compile-time constant but can be overwritten by the environment variable CONTRAP_INSTALL_PATH.

Returns:
Installation path of ContRap
static Options* crp::Options::get_instance ( ) [static]

Returns the singleton instance of the class.

Returns:
Instance of the options
const std::vector<std::string>& crp::Options::get_search_paths ( ) const [inline]

Returns the search paths were ContRap looks for plugins.

Returns:
Search paths
const std::vector<std::string>& crp::Options::get_template_paths ( ) const [inline]

Returns the search paths were ContRap looks for templates.

Returns:
Search paths
bool crp::Options::is_worksheet ( ) [inline]

Returns true if the core library was initialized in worksheet mode.

Returns:
True if the library is in worksheet mode.
void crp::Options::set_arguments ( int  argc,
char **  argv 
)

Sets the command line arguments.

Parameters:
argcArguments count
argvArgument values
void crp::Options::set_worksheet ( bool  status) [inline]

Sets the worksheet mode.

In the worksheet mode widgets, images and so on are not shown by default on creation.

Parameters:
statusTrue if the worksheet mode is on.
void crp::Options::update ( ) [protected]

Updates the options.

void crp::Options::update_cache ( )

Updates the cache information.


Field Documentation

int crp::Options::argc [protected]

Command line arguments.

char** crp::Options::argv [protected]
std::map<std::string, std::string> crp::Options::icon_cache [protected]

Icon cache.

std::vector<std::string> crp::Options::icon_paths [protected]

Icon search paths.

std::string crp::Options::install_path [protected]

Install path of contrap.

Options* crp::Options::options [static, protected]

Options instance.

std::vector<std::string> crp::Options::search_paths [protected]

Search paths.

std::vector<std::string> crp::Options::template_paths [protected]

Template paths.

bool crp::Options::worksheet [protected]

Worksheet mode.


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