Rcpp Version 0.12.12
PreserveStorage.h
Go to the documentation of this file.
1 #ifndef Rcpp_PreserveStorage_h
2 #define Rcpp_PreserveStorage_h
3 
4 namespace Rcpp{
5 
6  template <typename CLASS>
8  public:
9 
10  PreserveStorage() : data(R_NilValue){}
11 
14  data = R_NilValue;
15  }
16 
17  inline void set__(SEXP x){
19 
20  // calls the update method of CLASS
21  // this is where to react to changes in the underlying SEXP
22  static_cast<CLASS&>(*this).update(data) ;
23  }
24 
25  inline SEXP get__() const {
26  return data ;
27  }
28 
29  inline SEXP invalidate__(){
30  SEXP out = data ;
31  data = R_NilValue ;
32  return out ;
33  }
34 
35  template <typename T>
36  inline T& copy__(const T& other){
37  if( this != &other){
38  set__(other.get__());
39  }
40  return static_cast<T&>(*this) ;
41  }
42 
43  inline bool inherits(const char* clazz) const {
44  return ::Rf_inherits( data, clazz) ;
45  }
46 
47  inline operator SEXP() const { return data; }
48 
49  private:
50  SEXP data ;
51  } ;
52 
53 }
54 
55 #endif
SEXP Rcpp_ReplaceObject(SEXP x, SEXP y)
Definition: RcppCommon.h:97
T & copy__(const T &other)
bool inherits(const char *clazz) const
Rcpp API.
Definition: algo.h:28
void Rcpp_ReleaseObject(SEXP x)
Definition: RcppCommon.h:91