Rcpp Version 1.1.2
Loading...
Searching...
No Matches
S4.h
Go to the documentation of this file.
1
2// S4.h: Rcpp R/C++ interface class library -- S4 objects
3//
4// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois
5//
6// This file is part of Rcpp.
7//
8// Rcpp is free software: you can redistribute it and/or modify it
9// under the terms of the GNU General Public License as published by
10// the Free Software Foundation, either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rcpp is distributed in the hope that it will be useful, but
14// WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20
21#ifndef Rcpp_S4_h
22#define Rcpp_S4_h
23
24namespace Rcpp{
25
29 RCPP_API_CLASS(S4_Impl) {
30 public:
32
33 S4_Impl(){} ;
34
40 S4_Impl(SEXP x) { // #nocov start
41 if( ! ::Rf_isS4(x) ) throw not_s4() ;
42 Storage::set__(x) ;
43 } // #nocov end
44
45 S4_Impl& operator=( SEXP other ){
46 Storage::set__( other ) ;
47 return *this ;
48 }
49
56 S4_Impl( const std::string& klass ){
57 Shield<SEXP> x( R_do_new_object(R_do_MAKE_CLASS(klass.c_str())) );
58 if (!Rf_inherits(x, klass.c_str()))
59 throw S4_creation_error( klass ) ; // #nocov
60 Storage::set__(x) ;
61 }
62
66 bool is( const std::string& clazz) const ;
67
71 void update(SEXP x){
72 if( ! ::Rf_isS4(x) ) throw not_s4() ;
73 }
74 } ;
75
76 typedef S4_Impl<PreserveStorage> S4 ;
77
78} // namespace Rcpp
79
80#endif
#define RCPP_GENERATE_CTOR_ASSIGN(__CLASS__)
Definition interface.h:21
#define RCPP_API_CLASS(__CLASS__)
Definition interface.h:49
Rcpp API.
Definition algo.h:28
void update(SEXP)
bool is(SEXP x)
Definition is.h:53
S4_Impl< PreserveStorage > S4
Definition S4.h:76