1 // Module.h: Rcpp R/C++ interface class library -- Rcpp modules
2 //
3 // Copyright (C) 2013 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_api_meat_Module_h
21 #define Rcpp_api_meat_Module_h
22 
23 namespace Rcpp {
24 
classes_info()25     inline List Module::classes_info(){
26 	    size_t n = classes.size() ;
27 	    CharacterVector names(n) ;
28 	    List info(n);
29 	    CLASS_MAP::iterator it = classes.begin() ;
30 	    std::string buffer ;
31 	    for( size_t i=0; i<n; i++, ++it){
32 	        names[i] = it->first ;
33 	        info[i]  = CppClass( this , it->second, buffer ) ;
34 	    }
35 	    info.names() = names ;
36 	    return info ;
37 	}
38 
get_class(const std::string & cl)39     inline CppClass Module::get_class( const std::string& cl ){
40         BEGIN_RCPP
41             CLASS_MAP::iterator it = classes.find(cl) ;
42             if( it == classes.end() ) throw std::range_error( "no such class" ) ;
43             std::string buffer ;
44             return CppClass( this, it->second, buffer ) ;
45         END_RCPP
46     }
47 
48 }
49 
50 #endif
51