Wallaroo 是一个C++的依赖注入库,您可以使用字符串来创建对象,你也可以从配置文件中加载“对象图”。
示例代码:
#include "wallaroo/catalog.h" using namespace wallaroo; ... // load classes in shared libraries: Plugin::Load( "car" + Plugin::Suffix() ); // Plugin::Suffix() expands to .dll or .so according to the OS ... Catalog catalog; // this is the container of your objects // populate the catalog with some objects: catalog.Create( "ferrari_f430", "Car" ); catalog.Create( "maserati_granturismo", "Car" );