/* * Boost.Extension / car library implementations * * (C) Copyright Mariano G. Consoni 2008 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org/ for latest version. */ #include "../car.hpp" #include #include using namespace boost::reflections; // Although both of these classes are derived from a common // base, this is certainly not necessary. If we were using // Boost.Extension factories, this would be required. class suv { public: suv(const char * name) {} const char* get_type(void) { return "It's an SUV."; } void start() {} bool start(int target_speed) {} short year; }; class compact : public car { public: compact(const char * name) : car(name) {} virtual const char * get_type(void) { return "It's a compact."; } virtual ~compact(void) {} }; extern "C" void BOOST_EXTENSION_EXPORT_DECL extension_export_car(std::map reflection_map) { reflection_map["suv"].reflect() .constructor() .function(&suv::get_type, "get_type") .data(&suv::year, "year") .function(&suv::start, "start") .function(&suv::start, "start"); reflection_map["compact"].reflect() .constructor() .function(&compact::get_type, "get_type"); }