Rcpp Version 1.0.9
TagProxy.h
Go to the documentation of this file.
1 // Copyright (C) 2013 Romain Francois
2 //
3 // This file is part of Rcpp.
4 //
5 // Rcpp is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // Rcpp is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef Rcpp_TagProxy_h
19 #define Rcpp_TagProxy_h
20 
21 namespace Rcpp{
22 
23  template <typename XPtrClass>
25  public:
26 
27  class TagProxy : public GenericProxy<TagProxy>{
28  public:
29  TagProxy( XPtrClass& xp_ ): xp(xp_){}
30 
31  template <typename U>
32  TagProxy& operator=( const U& u);
33 
34  template <typename U>
35  operator U() const;
36 
37  operator SEXP() const;
38 
39 
40  private:
41  XPtrClass& xp ;
42 
43  inline SEXP get() const {
44  return R_ExternalPtrTag(xp) ;
45  }
46 
47  inline void set( SEXP x){
48  R_SetExternalPtrTag( xp, x ) ;
49  }
50 
51  } ;
52 
53  class const_TagProxy : public GenericProxy<const_TagProxy>{
54  public:
55  const_TagProxy( XPtrClass& xp_ ): xp(xp_){}
56 
57  template <typename U>
58  operator U() const;
59 
60  operator SEXP() const;
61 
62 
63  private:
64  XPtrClass& xp ;
65 
66  inline SEXP get() const {
67  return R_ExternalPtrTag(xp) ;
68  }
69 
70  } ;
71 
72 
74  return TagProxy( static_cast<XPtrClass&>(*this) ) ;
75  }
76 
77  const_TagProxy tag() const {
78  return TagProxy( static_cast<const XPtrClass&>(*this) ) ;
79  }
80 
81 
82  } ;
83 }
84 
85 #endif
TagProxy & operator=(const U &u)
TagProxy(XPtrClass &xp_)
Definition: TagProxy.h:29
TagProxy tag()
Definition: TagProxy.h:73
const_TagProxy tag() const
Definition: TagProxy.h:77
Rcpp API.
Definition: algo.h:28