Graphite  Version 3
An experimental 3D geometry processing program
OGF::FileManager Class Reference

FileManager retreives the files used by Graphite (icons, plugins). More...

#include <OGF/basic/os/file_manager.h>

Inheritance diagram for OGF::FileManager:
GEO::Environment GEO::Counted

Public Member Functions

bool find_file (std::string &file_name, bool verbose=true, const std::string &sub_path="lib/") const
 Finds a file. More...
 
bool find_binary_file (std::string &file_name, bool verbose=true) const
 Finds a binary file, such as the DLL of a plugin. More...
 
std::string dll_prefix () const
 Gets the prefix of dynamically loadable libraries file names. More...
 
std::string dll_extension () const
 Gets the extension of dynamically loadable libraries file names. More...
 
std::string libraries_subdirectory () const
 Gets the relative subdirectory where dynamic libraries are stored. More...
 
const std::vector< std::string > & ogf_path () const
 Gets the OGF Path, i.e. the list of directories where files are searched. More...
 
const std::string & project_root () const
 Gets Graphite project root. More...
 
bool get_local_value (const std::string &name, std::string &value) const override
 Retrieves a variable value locally. More...
 
bool set_local_value (const std::string &name, const std::string &value) override
 Sets a variable value locally. More...
 
- Public Member Functions inherited from GEO::Environment
virtual bool add_environment (Environment *env)
 Adds a child environment. More...
 
bool has_value (const std::string &name) const
 Tests if a variable exists. More...
 
virtual bool get_value (const std::string &name, std::string &value) const
 Retrieves the value of a variable. More...
 
std::string get_value (const std::string &name) const
 Retrieves the value of a variable. More...
 
virtual bool set_value (const std::string &name, const std::string &value)
 Sets a variable value. More...
 
virtual Environmentfind_environment (const std::string &name)
 Finds the environment that declares a variable as a local name. More...
 
virtual bool add_observer (const std::string &name, VariableObserver *observer)
 Attaches an observer to a variable. More...
 
virtual bool remove_observer (const std::string &name, VariableObserver *observer)
 Detaches an observer from a variable. More...
 
virtual bool notify_observers (const std::string &name, bool recursive=false)
 Notifies observers. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Static Public Member Functions

static void initialize ()
 Initializes the FileManager. More...
 
static void terminate ()
 Terminates the FileManager. More...
 
static FileManagerinstance ()
 Gets a pointer to the instance of the FileManager. More...
 
- Static Public Member Functions inherited from GEO::Environment
static Environmentinstance ()
 Gets the root environment. More...
 
static void terminate ()
 Cleans up the environment. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GEO::Environment
 ~Environment () override
 Environment destructor. More...
 
bool notify_observers (const std::string &name, const std::string &value, bool recursive)
 Notifies observers. More...
 
bool notify_local_observers (const std::string &name, const std::string &value)
 Notifies local observers. More...
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Detailed Description

FileManager retreives the files used by Graphite (icons, plugins).

Internally, FileManager manages a path where to search for the files. This path contains the main Graphite path and the path to the loaded plugins.

Definition at line 63 of file file_manager.h.

Member Function Documentation

◆ dll_extension()

std::string OGF::FileManager::dll_extension ( ) const

Gets the extension of dynamically loadable libraries file names.

Under Unix, ".so", and under Windows, ".dll".

Returns
the extension of dynamically loadable libraries file names.

◆ dll_prefix()

std::string OGF::FileManager::dll_prefix ( ) const

Gets the prefix of dynamically loadable libraries file names.

Under Unix, "lib", and under Windows, empty string.

Returns
the prefix of dynamically loadable libraries file names.

◆ find_binary_file()

bool OGF::FileManager::find_binary_file ( std::string &  file_name,
bool  verbose = true 
) const

Finds a binary file, such as the DLL of a plugin.

Parameters
[in,out]file_namethe name to be found, as specified by the user (without "lib" prefix, without ".dll" or ".so" suffix). On exit, if found, the full path to the file (with "lib" prefix, with ".dll" or ".so" suffix).
[in]verboseif true, messages are logged on success and failure
Return values
trueif the file was found
falseotherwise

◆ find_file()

bool OGF::FileManager::find_file ( std::string &  file_name,
bool  verbose = true,
const std::string &  sub_path = "lib/" 
) const

Finds a file.

Parameters
[in,out]file_namethe name to be found. On exit, if found, the full path to the file
[in]verboseif true, messages are logged on success and failure
[in]sub_patha relative path that is prepended to the file name before searching
Return values
trueif the file was found
falseotherwise

◆ get_local_value()

bool OGF::FileManager::get_local_value ( const std::string &  name,
std::string &  value 
) const
overridevirtual

Retrieves a variable value locally.

This function is used internally. It searches variable name locally and stores its value in the output string value.

Parameters
[in]namethe name of the variable
[out]valueis set the variable value if it was found locally.
Return values
trueif the variable was found
falseif not
Note
This function must be reimplemented in derived custom environments.

Defines PROJECT_ROOT and OGF_PATH environment variables.

Implements GEO::Environment.

◆ initialize()

static void OGF::FileManager::initialize ( )
static

Initializes the FileManager.

This function is called once when Graphite starts (does not need to be called by client code).

◆ instance()

static FileManager* OGF::FileManager::instance ( )
static

Gets a pointer to the instance of the FileManager.

Returns
A pointer to the instance of the FileManager.

◆ libraries_subdirectory()

std::string OGF::FileManager::libraries_subdirectory ( ) const

Gets the relative subdirectory where dynamic libraries are stored.

It is different under Unix and Windows. Under Unix, they are in a separate "lib/" subdirectory. Under Windows, they are in the same directory as the main executable.

◆ ogf_path()

const std::vector<std::string>& OGF::FileManager::ogf_path ( ) const
inline

Gets the OGF Path, i.e. the list of directories where files are searched.

Returns
a const reference to an array of strings, each of which corresponding an entry in the OGF path.

Definition at line 148 of file file_manager.h.

◆ project_root()

const std::string& OGF::FileManager::project_root ( ) const
inline

Gets Graphite project root.

The element of the OGF Path that contains Graphite's main executable. It is always the first element of the OGF Path.

Returns
Graphite project root.

Definition at line 158 of file file_manager.h.

◆ set_local_value()

bool OGF::FileManager::set_local_value ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Sets a variable value locally.

This function is used internally. It sets the variable named name to the given value locally.

Parameters
[in]namethe name of the variable
[in]valuethe value of the variable
Return values
trueif the variable was successfully added locally
falseotherwise
Note
This function must be reimplemented in derived custom environments.

Does not define any new variable (does nothing and returns false).

Implements GEO::Environment.

◆ terminate()

static void OGF::FileManager::terminate ( )
static

Terminates the FileManager.

This function is called once when Graphite stops (does not need to be called by client code).


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