40#ifndef GEOGRAM_BASIC_ENVIRONMENT
41#define GEOGRAM_BASIC_ENVIRONMENT
114 return observed_variable_;
118 std::string observed_variable_;
135 block_notify_(false) {
160 typedef std::vector<VariableObserver*> Observers;
161 Observers observers_;
258 const std::string& name, std::string& value
287 const std::string& name,
const std::string& value
345 const std::string& name,
bool recursive =
false
369 const std::string& name, std::string& value
384 const std::string& name,
const std::string& value
400 const std::string& name,
const std::string& value,
415 const std::string& name,
const std::string& value
423 typedef std::vector<Environment_var> Environments;
426 typedef std::map<std::string, VariableObserverList> ObserverMap;
429 Environments environments_;
430 ObserverMap observers_;
453 const std::string& name,
const std::string& value
462 const std::string& name, std::string& value
Common include file, providing basic definitions. Should be included before anything else by all head...
Base class for reference-counted objects.
static Environment * instance()
Gets the root environment.
virtual bool set_value(const std::string &name, const std::string &value)
Sets a variable value.
virtual bool get_value(const std::string &name, std::string &value) const
Retrieves the value of a variable.
virtual bool set_local_value(const std::string &name, const std::string &value)=0
Sets a variable value locally.
virtual Environment * find_environment(const std::string &name)
Finds the environment that declares a variable as a local name.
~Environment() override
Environment destructor.
virtual bool notify_observers(const std::string &name, bool recursive=false)
Notifies observers.
virtual bool add_environment(Environment *env)
Adds a child environment.
virtual bool add_observer(const std::string &name, VariableObserver *observer)
Attaches an observer to a variable.
bool notify_local_observers(const std::string &name, const std::string &value)
Notifies local observers.
bool has_value(const std::string &name) const
Tests if a variable exists.
static void terminate()
Cleans up the environment.
bool notify_observers(const std::string &name, const std::string &value, bool recursive)
Notifies observers.
std::string get_value(const std::string &name) const
Retrieves the value of a variable.
virtual bool get_local_value(const std::string &name, std::string &value) const =0
Retrieves a variable value locally.
virtual bool remove_observer(const std::string &name, VariableObserver *observer)
Detaches an observer from a variable.
A smart pointer with reference-counted copy semantics.
~SystemEnvironment() override
bool set_local_value(const std::string &name, const std::string &value) override
Sets a variable value locally.
bool get_local_value(const std::string &name, std::string &value) const override
Retrieves a variable value locally.
List of VariableObservers.
VariableObserverList()
Creates an empty list of variable observers.
void notify_observers(const std::string &value)
Notifies all observers in the list.
void remove_observer(VariableObserver *observer)
Removes an observer from the list.
void add_observer(VariableObserver *observer)
Adds an observer to the list. This adds observer observer at the end of the list only if it is not al...
Observes Environment variables.
virtual ~VariableObserver()
Deletes the observer.
VariableObserver(const std::string &var_name)
Creates a new variable observer.
virtual void value_changed(const std::string &new_value)=0
Receives a change notification.
const std::string & observed_variable() const
Gets the observed variable.
Base class of reference-counted objects, to be used with smart pointers.
Global Vorpaline namespace.
Pointers with automatic reference counting.