Rcpp Version 1.0.9
Armor.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_protection_Armor_H
19 #define Rcpp_protection_Armor_H
20 
21 namespace Rcpp {
22 
23  template <typename T>
24  class Armor {
25  public:
26 
27  Armor() : data(){
28  init(R_NilValue) ;
29  }
30 
31  template <typename U> Armor( U x );
32 
33  inline operator SEXP() const {
34  return data ;
35  }
36 
37  template <typename U>
38  inline Armor& operator=( const U& x ) ;
39 
40  ~Armor(){
41  UNPROTECT(1) ;
42  }
43 
44  private:
45  void init(SEXP x){
46  PROTECT_WITH_INDEX( data = x, &index ) ;
47  }
48 
49  SEXP data ;
50  PROTECT_INDEX index ;
51 
52  // not defined on purpose
53  Armor(const Armor&) ;
54  Armor& operator=(const Armor&) ;
55  } ;
56 }
57 
58 #endif
PROTECT_INDEX index
Definition: Armor.h:50
void init(SEXP x)
Definition: Armor.h:45
Armor(const Armor &)
~Armor()
Definition: Armor.h:40
Armor & operator=(const Armor &)
Armor & operator=(const U &x)
Armor()
Definition: Armor.h:27
SEXP data
Definition: Armor.h:49
Rcpp API.
Definition: algo.h:28