00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * This file is example code for XPLC (http://xplc.sourceforge.net/), 00004 * and is put into the public domain. 00005 */ 00006 00007 #include <stdio.h> 00008 #include <xplc/xplc.h> 00009 #include "IExample.h" 00010 #include "simple.h" 00011 00012 /* 00013 * This is an helper class from the C++ binding. While it is not XPLC 00014 * itself (despite the name), it makes XPLC itself easier to use in 00015 * C++. 00016 * 00017 * It should live at least as long as you intend to use XPLC, as it 00018 * keeps it alive. 00019 * 00020 * Although this wastes a tiny bit of space, it is allowed to have 00021 * more than one XPLC helper object in a single process, since XPLC 00022 * uses reference counting. This is useful for libraries, which can 00023 * create their own XPLC helper object, and if the main application 00024 * also uses XPLC, or if another library used by the application uses 00025 * XPLC (even if the application doesn't!), they will be able to 00026 * cooperate through XPLC. 00027 */ 00028 XPLC xplc; 00029 00030 int main() { 00031 xplc.addModuleDirectory("../simple-module"); 00032 00033 xplc_ptr<IExample> example(xplc.get<IExample>(SimpleComponent_CID)); 00034 00035 if (example) { 00036 example->sayHello(); 00037 } else { 00038 printf("SimpleComponent not found\n"); 00039 } 00040 00041 return 0; 00042 } 00043