Rcpp Version 1.0.14
Loading...
Searching...
No Matches
generic_proxy.h
Go to the documentation of this file.
1// generic_proxy.h: Rcpp R/C++ interface class library --
2//
3// Copyright (C) 2010 - 2018 Dirk Eddelbuettel and Romain Francois
4//
5// This file is part of Rcpp.
6//
7// Rcpp is free software: you can redistribute it and/or modify it
8// under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 2 of the License, or
10// (at your option) any later version.
11//
12// Rcpp is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
19
20#ifndef Rcpp__vector__generic_proxy_h
21#define Rcpp__vector__generic_proxy_h
22
23namespace Rcpp{
24namespace internal{
25
26 template <int RTYPE, template <class> class StoragePolicy>
27 class generic_proxy : public GenericProxy< generic_proxy<RTYPE, StoragePolicy> > {
28 public:
29 typedef typename ::Rcpp::Vector<RTYPE, StoragePolicy> VECTOR ;
30
32
36
38 parent(&v), index(i)
39 {}
40
42 set(rhs) ;
43 return *this ;
44 }
45
47 set(rhs.get());
48 return *this ;
49 }
50
51 template <template <class> class StoragePolicy2>
53 set(rhs.get());
54 return *this ;
55 }
56
57 template <typename T>
58 generic_proxy& operator=( const T& rhs){
59 set(Shield<SEXP>(wrap(rhs))) ;
60 return *this;
61 }
62
63 operator SEXP() const {
64 return get() ;
65 }
66
67 template <typename U> operator U() const {
68 return ::Rcpp::as<U>(get()) ;
69 }
70
71 // helping the compiler (not sure why it can't help itself)
72 operator bool() const { return ::Rcpp::as<bool>(get()) ; }
73 operator int() const { return ::Rcpp::as<int>(get()) ; }
74
77 set( other.get() ) ;
78 other.set(tmp) ;
79 }
80
83 inline void move(R_xlen_t n) { index += n ; }
84
85 void import( const generic_proxy& other){
86 parent = other.parent ;
87 index = other.index ;
88 }
89
90 inline SEXP get() const {
91 return VECTOR_ELT(*parent, index );
92 }
93
94 private:
95 inline void set(SEXP x) {
97 }
98
99
100 } ;
101
102}
103}
104
105#endif
generic_proxy & operator=(const generic_proxy< RTYPE, StoragePolicy2 > &rhs)
void swap(generic_proxy &other)
generic_proxy(const generic_proxy &other)
::Rcpp::Vector< RTYPE, StoragePolicy > VECTOR
generic_proxy & operator=(const generic_proxy &rhs)
generic_proxy & operator=(const T &rhs)
generic_proxy & operator=(SEXP rhs)
generic_proxy(VECTOR &v, R_xlen_t i)
T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag)
Definition as.h:43
Rcpp API.
Definition algo.h:28
SEXP wrap(const Date &date)
Definition Date.h:38