Rcpp Version 1.0.9
class_Base.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // class_Base.h: Rcpp R/C++ interface class library -- Rcpp modules
4 //
5 // Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois
6 //
7 // This file is part of Rcpp.
8 //
9 // Rcpp is free software: you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // Rcpp is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef Rcpp_Module_Class_Base_h
23 
24 namespace Rcpp{
25 
26 class class_Base {
27 public:
29 
30  class_Base() : name(), docstring(), enums(), parents() {} ;
31  class_Base(const char* name_, const char* doc) :
32  name(name_), docstring( doc == 0 ? "" : doc ), enums(), parents() {} ;
33 
34  virtual Rcpp::List fields(const XP_Class& ){ return Rcpp::List(0); }
35  virtual Rcpp::List getMethods(const XP_Class&, std::string&){ return Rcpp::List(0); }
36  virtual Rcpp::List getConstructors(const XP_Class&, std::string&){ return Rcpp::List(0); }
37 
38  virtual void run_finalizer(SEXP){ }
39 
40  virtual bool has_default_constructor(){ return false ; }
41  virtual bool has_method( const std::string& ){
42  return false ;
43  }
44  virtual bool has_property( const std::string& ) {
45  return false ;
46  }
47  virtual SEXP newInstance(SEXP *, int){
48  return R_NilValue;
49  }
50  virtual SEXP invoke( SEXP, SEXP, SEXP *, int ){
51  return R_NilValue ;
52  }
53  virtual SEXP invoke_void( SEXP, SEXP, SEXP *, int ){
54  return R_NilValue ;
55  }
56  virtual SEXP invoke_notvoid( SEXP, SEXP, SEXP *, int ){
57  return R_NilValue ;
58  }
59 
62  virtual bool property_is_readonly(const std::string& ) { return false ; }
63  virtual std::string property_class(const std::string& ) { return "" ; }
66  virtual Rcpp::List property_classes(){ return Rcpp::List(0); }
67 
69  virtual ~class_Base(){}
70 
71  virtual SEXP getProperty( SEXP, SEXP ) {
72  throw std::range_error( "cannot retrieve property" ) ;
73  }
74  virtual void setProperty( SEXP, SEXP, SEXP) {
75  throw std::range_error( "cannot set property" ) ;
76  }
77  virtual std::string get_typeinfo_name(){ return "" ; }
78  bool has_typeinfo_name( const std::string& name_ ){
79  return get_typeinfo_name().compare(name_) == 0;
80  }
81  void add_enum( const std::string& enum_name, const std::map<std::string, int>& value ){
82  enums.insert( ENUM_MAP_PAIR( enum_name, value ) ) ;
83  }
84 
85  std::string name ;
86  std::string docstring ;
87 
88  typedef std::map< std::string, int > ENUM ;
89  typedef std::map< std::string, ENUM > ENUM_MAP ;
90  typedef ENUM_MAP::value_type ENUM_MAP_PAIR ;
92  std::vector<std::string> parents ;
93 
94 } ;
95 
96 }
97 #endif
std::map< std::string, int > ENUM
Definition: class_Base.h:88
std::string docstring
Definition: class_Base.h:86
virtual SEXP newInstance(SEXP *, int)
Definition: class_Base.h:47
ENUM_MAP::value_type ENUM_MAP_PAIR
Definition: class_Base.h:90
virtual ~class_Base()
Definition: class_Base.h:69
virtual bool property_is_readonly(const std::string &)
Definition: class_Base.h:62
std::map< std::string, ENUM > ENUM_MAP
Definition: class_Base.h:89
virtual void setProperty(SEXP, SEXP, SEXP)
Definition: class_Base.h:74
virtual SEXP invoke_void(SEXP, SEXP, SEXP *, int)
Definition: class_Base.h:53
virtual std::string get_typeinfo_name()
Definition: class_Base.h:77
virtual bool has_method(const std::string &)
Definition: class_Base.h:41
virtual bool has_property(const std::string &)
Definition: class_Base.h:44
std::string name
Definition: class_Base.h:85
virtual Rcpp::LogicalVector methods_voidness()
Definition: class_Base.h:65
virtual Rcpp::CharacterVector complete()
Definition: class_Base.h:68
class_Base(const char *name_, const char *doc)
Definition: class_Base.h:31
virtual Rcpp::IntegerVector methods_arity()
Definition: class_Base.h:64
virtual Rcpp::List getConstructors(const XP_Class &, std::string &)
Definition: class_Base.h:36
ENUM_MAP enums
Definition: class_Base.h:91
virtual bool has_default_constructor()
Definition: class_Base.h:40
virtual Rcpp::List property_classes()
Definition: class_Base.h:66
virtual Rcpp::List fields(const XP_Class &)
Definition: class_Base.h:34
virtual Rcpp::List getMethods(const XP_Class &, std::string &)
Definition: class_Base.h:35
virtual Rcpp::CharacterVector property_names()
Definition: class_Base.h:61
virtual SEXP invoke_notvoid(SEXP, SEXP, SEXP *, int)
Definition: class_Base.h:56
std::vector< std::string > parents
Definition: class_Base.h:92
void add_enum(const std::string &enum_name, const std::map< std::string, int > &value)
Definition: class_Base.h:81
virtual Rcpp::CharacterVector method_names()
Definition: class_Base.h:60
virtual SEXP getProperty(SEXP, SEXP)
Definition: class_Base.h:71
bool has_typeinfo_name(const std::string &name_)
Definition: class_Base.h:78
virtual void run_finalizer(SEXP)
Definition: class_Base.h:38
virtual std::string property_class(const std::string &)
Definition: class_Base.h:63
virtual SEXP invoke(SEXP, SEXP, SEXP *, int)
Definition: class_Base.h:50
Rcpp::XPtr< class_Base > XP_Class
Definition: class_Base.h:28
Rcpp API.
Definition: algo.h:28
Vector< STRSXP > CharacterVector
Definition: instantiation.h:34
Vector< LGLSXP > LogicalVector
Definition: instantiation.h:29
Vector< INTSXP > IntegerVector
Definition: instantiation.h:28
Vector< VECSXP > List
Definition: instantiation.h:37