Rcpp Version 0.9.10
Rcpp::Environment Class Reference

#include <Environment.h>

Inheritance diagram for Rcpp::Environment:
Collaboration diagram for Rcpp::Environment:

List of all members.

Classes

class  Binding

Public Member Functions

const Binding operator[] (const std::string &name) const
Binding operator[] (const std::string &name)
 Environment ()
 Environment (SEXP x)
 Environment (const Environment &other)
Environmentoperator= (const Environment &other)
 Environment (const std::string &name)
 Environment (int pos)
 ~Environment ()
SEXP ls (bool all) const
SEXP get (const std::string &name) const
SEXP find (const std::string &name) const
bool exists (const std::string &name) const
bool assign (const std::string &name, SEXP x) const
template<typename WRAPPABLE >
bool assign (const std::string &name, const WRAPPABLE &x) const
bool isLocked () const
bool remove (const std::string &name)
void lock (bool bindings)
void lockBinding (const std::string &name)
void unlockBinding (const std::string &name)
bool bindingIsLocked (const std::string &name) const
bool bindingIsActive (const std::string &name) const
bool is_user_database () const
Environment parent () const
Environment new_child (bool hashed)

Static Public Member Functions

static Environment global_env ()
static Environment empty_env ()
static Environment base_env ()
static Environment base_namespace ()
static Environment Rcpp_namespace ()
static Environment namespace_env (const std::string &)

Friends

class Binding

Detailed Description

Definition at line 35 of file Environment.h.


Constructor & Destructor Documentation

Rcpp::Environment::Environment ( )
Rcpp::Environment::Environment ( SEXP  x = R_GlobalEnv)

wraps the given environment

if the SEXP is not an environment, and exception is thrown

Definition at line 28 of file Environment.cpp.

References Rcpp::Evaluator::run(), Rcpp::RObject::setSEXP(), and x.

Here is the call graph for this function:

Rcpp::Environment::Environment ( const Environment other)

copy constructor

Definition at line 71 of file Environment.cpp.

References Rcpp::RObject::asSexp(), and Rcpp::RObject::setSEXP().

Here is the call graph for this function:

Rcpp::Environment::Environment ( const std::string &  name)

Gets the environment associated with the given name

Parameters:
namename of the environment, e.g "package:Rcpp"

Definition at line 42 of file Environment.cpp.

References R_NilValue, Rcpp::Evaluator::run(), and Rcpp::RObject::setSEXP().

Here is the call graph for this function:

Rcpp::Environment::Environment ( int  pos)

Gets the environment in the given position of the search path

Parameters:
pos(1-based) position of the environment, e.g pos=1 gives the global environment

Definition at line 60 of file Environment.cpp.

References Rcpp::Evaluator::run(), and Rcpp::RObject::setSEXP().

Here is the call graph for this function:

Rcpp::Environment::~Environment ( )

Nothing specific

Definition at line 80 of file Environment.cpp.

References logTxt.


Member Function Documentation

bool Rcpp::Environment::assign ( const std::string &  name,
SEXP  x = R_NilValue 
) const

Attempts to assign x to name in this environment

Parameters:
namename of the object to assign
xobject to assign
Returns:
true if the assign was successfull see ?bindingIsLocked
Exceptions:
binding_is_lockedif the binding is locked

Definition at line 128 of file Environment.cpp.

References bindingIsLocked(), exists(), Rcpp::RObject::m_sexp, and x.

Referenced by assign(), and Rcpp::Environment::Binding::operator=().

Here is the call graph for this function:

template<typename WRAPPABLE >
bool Rcpp::Environment::assign ( const std::string &  name,
const WRAPPABLE &  x 
) const [inline]

wrap and assign. If there is a wrap method taking an object of WRAPPABLE type, then it is wrapped and the corresponding SEXP is assigned in the environment

Parameters:
namename of the object to assign
xwrappable object. anything that has a wrap( WRAPPABLE ) is fine

Definition at line 269 of file Environment.h.

References assign(), and Rcpp::wrap().

Here is the call graph for this function:

Environment Rcpp::Environment::base_env ( ) [static]
Returns:
the base environment. See ?baseenv

Definition at line 201 of file Environment.cpp.

References Environment().

Here is the call graph for this function:

Environment Rcpp::Environment::base_namespace ( ) [static]
Returns:
the base namespace. See ?baseenv

Definition at line 205 of file Environment.cpp.

References Environment().

Here is the call graph for this function:

bool Rcpp::Environment::bindingIsActive ( const std::string &  name) const
Parameters:
namename of a binding
Returns:
true if the binding is active in this environment see ?bindingIsActive
Exceptions:
no_such_bindingif there is no such binding in this environment

Definition at line 159 of file Environment.cpp.

References exists(), and Rcpp::RObject::m_sexp.

Here is the call graph for this function:

bool Rcpp::Environment::bindingIsLocked ( const std::string &  name) const
Parameters:
namename of a potential binding
Returns:
true if the binding is locked in this environment see ?bindingIsLocked
Exceptions:
no_such_bindingif there is no such binding in this environment

Definition at line 165 of file Environment.cpp.

References exists(), and Rcpp::RObject::m_sexp.

Referenced by assign(), and remove().

Here is the call graph for this function:

Environment Rcpp::Environment::empty_env ( ) [static]
Returns:
The empty environment. See ?emptyenv

Definition at line 197 of file Environment.cpp.

References Environment().

Here is the call graph for this function:

bool Rcpp::Environment::exists ( const std::string &  name) const

Indicates if an object called name exists in the environment

Parameters:
namename of the object
Returns:
true if the object exists in the environment

Definition at line 122 of file Environment.cpp.

References Rcpp::RObject::m_sexp.

Referenced by assign(), bindingIsActive(), bindingIsLocked(), lockBinding(), remove(), and unlockBinding().

SEXP Rcpp::Environment::find ( const std::string &  name) const

Get an object from the environment or one of its parents

Parameters:
namename of the object

Definition at line 109 of file Environment.cpp.

References Rcpp::RObject::m_sexp.

SEXP Rcpp::Environment::get ( const std::string &  name) const

Get an object from the environment

Parameters:
namename of the object
Returns:
a SEXP (possibly R_NilValue)

Definition at line 96 of file Environment.cpp.

References Rcpp::RObject::m_sexp, and R_NilValue.

Referenced by Rcpp::Environment::Binding::operator T(), and Rcpp::Environment::Binding::operator=().

Environment Rcpp::Environment::global_env ( ) [static]
Returns:
the global environment. See ?globalenv

Definition at line 193 of file Environment.cpp.

References Environment().

Here is the call graph for this function:

bool Rcpp::Environment::is_user_database ( ) const

Indicates if this is a user defined database.

Definition at line 187 of file Environment.cpp.

References Rcpp::RObject::m_sexp.

Referenced by ls().

bool Rcpp::Environment::isLocked ( ) const
Returns:
true if this environment is locked see ?environmentIsLocked for details of what this means

Definition at line 155 of file Environment.cpp.

References Rcpp::RObject::m_sexp.

void Rcpp::Environment::lock ( bool  bindings = false)

locks this environment. See ?lockEnvironment

Parameters:
bindingsalso lock the bindings of this environment ?

Definition at line 171 of file Environment.cpp.

References Rcpp::RObject::m_sexp.

void Rcpp::Environment::lockBinding ( const std::string &  name)

Locks the given binding in the environment. see ?bindingIsLocked

Exceptions:
no_such_bindingif there is no such binding in this environment

Definition at line 175 of file Environment.cpp.

References exists(), and Rcpp::RObject::m_sexp.

Here is the call graph for this function:

SEXP Rcpp::Environment::ls ( bool  all = true) const

The list of objects in the environment

the same as calling this from R: > ls( envir = this, all = all )

Parameters:
allsame meaning as in ?ls

Definition at line 84 of file Environment.cpp.

References Rcpp::all(), is_user_database(), Rcpp::RObject::m_sexp, and R_NilValue.

Here is the call graph for this function:

Environment Rcpp::Environment::namespace_env ( const std::string &  package) [static]
Parameters:
namethe name of the package of which we want the namespace
Returns:
the namespace of the package
Exceptions:
no_such_namespace

Definition at line 209 of file Environment.cpp.

References Environment(), R_NilValue, and Rcpp::Evaluator::run().

Here is the call graph for this function:

Environment Rcpp::Environment::new_child ( bool  hashed)

creates a new environment whose this is the parent

Definition at line 270 of file Environment.cpp.

References Environment(), Rcpp::RObject::m_sexp, and Rcpp::Evaluator::run().

Here is the call graph for this function:

Environment & Rcpp::Environment::operator= ( const Environment other)

assignment

Definition at line 75 of file Environment.cpp.

References Rcpp::RObject::asSexp(), and Rcpp::RObject::setSEXP().

Here is the call graph for this function:

Environment::Binding Rcpp::Environment::operator[] ( const std::string &  name)

Same as above, but for a non-const Environment

Definition at line 262 of file Environment.cpp.

References Binding.

const Environment::Binding Rcpp::Environment::operator[] ( const std::string &  name) const

Creates a binding for a variable in this environment

The Binding class is a proxy class, so depending on how the result of this operator call is used, the variable is either retrieved or modified. See the Binding class for details

Definition at line 258 of file Environment.cpp.

References Binding.

Environment Rcpp::Environment::parent ( ) const

The parent environment of this environment

Definition at line 221 of file Environment.cpp.

References Environment(), and Rcpp::RObject::m_sexp.

Here is the call graph for this function:

Environment Rcpp::Environment::Rcpp_namespace ( ) [static]
Returns:
the Rcpp namespace

Definition at line 266 of file Environment.cpp.

References Rcpp::internal::get_Rcpp_namespace().

Referenced by Rcpp::internal::make_new_object(), Rcpp::Evaluator::run(), and Rcpp::InternalFunction::set().

Here is the call graph for this function:

bool Rcpp::Environment::remove ( const std::string &  name)

remove an object from this environment

Definition at line 135 of file Environment.cpp.

References bindingIsLocked(), exists(), Rcpp::RObject::m_sexp, and PROTECT().

Here is the call graph for this function:

void Rcpp::Environment::unlockBinding ( const std::string &  name)

unlocks the given binding see ?bindingIsLocked

Exceptions:
no_such_bindingif there is no such binding in this environment

Definition at line 181 of file Environment.cpp.

References exists(), and Rcpp::RObject::m_sexp.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Binding [friend]

Definition at line 168 of file Environment.h.

Referenced by operator[]().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines