Rcpp Version 0.10.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
Rcpp::Environment Class Reference

#include <Environment.h>

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

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)
- Public Member Functions inherited from Rcpp::RObject
 RObject ()
 RObject (SEXP x)
 RObject (const RObject &other)
RObjectoperator= (const RObject &other)
RObjectoperator= (SEXP other)
virtual ~RObject ()
 operator SEXP () const
bool inherits (const char *clazz) const
std::vector< std::string > attributeNames () const
bool hasAttribute (const std::string &attr) const
AttributeProxy attr (const std::string &name) const
bool isNULL () const
int sexp_type () const
SEXP asSexp () const
bool isObject () const
bool isS4 () const
bool hasSlot (const std::string &name) const
SlotProxy slot (const std::string &name) const

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

Additional Inherited Members

- Protected Member Functions inherited from Rcpp::RObject
void setSEXP (SEXP x)
- Protected Attributes inherited from Rcpp::RObject
SEXP m_sexp

Detailed Description

Definition at line 29 of file Environment.h.

Constructor & Destructor Documentation

Rcpp::Environment::Environment ( )

Definition at line 926 of file api.cpp.

Referenced by base_env(), base_namespace(), empty_env(), global_env(), namespace_env(), new_child(), and parent().

Rcpp::Environment::Environment ( SEXP  x)

wraps the given environment

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

Definition at line 928 of file api.cpp.

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

Here is the call graph for this function:

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

copy constructor

Definition at line 971 of file api.cpp.

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 942 of file api.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 960 of file api.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 978 of file api.cpp.

References RCPP_DEBUG.

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 1026 of file api.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

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 28 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 1099 of file api.cpp.

References Environment().

Referenced by Rcpp::attributes::SourceFileAttributesParser::attributeWarning(), Rcpp::attributes::createDirectory(), Rcpp::GetCppCallable(), Rcpp::attributes::removeFile(), and Rcpp::attributes::showWarning().

Here is the call graph for this function:

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

Definition at line 1103 of file api.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 1057 of file api.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 1063 of file api.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 1095 of file api.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 1020 of file api.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 1007 of file api.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 994 of file api.cpp.

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

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

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

Definition at line 1091 of file api.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 1085 of file api.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 1053 of file api.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 1069 of file api.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 1073 of file api.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 982 of file api.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 1107 of file api.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 1168 of file api.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 973 of file api.cpp.

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

Here is the call graph for this function:

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 1156 of file api.cpp.

References Binding.

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

Same as above, but for a non-const Environment

Definition at line 1160 of file api.cpp.

References Binding.

Environment Rcpp::Environment::parent ( ) const

The parent environment of this environment

Definition at line 1119 of file api.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 1164 of file api.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 1033 of file api.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 1079 of file api.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 154 of file Environment.h.

Referenced by operator[]().


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