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 #ifndef __EXAMPLE_EXAMPLE_H__ 00008 #define __EXAMPLE_EXAMPLE_H__ 00009 00010 #include <xplc/IObject.h> 00011 00012 /* Interfaces can only derive from exactly one interface. They must 00013 * ultimately be derived from IObject. Since we do not derive from 00014 * anything else useful here, we derive from IObject directly. 00015 */ 00016 class IExample: public IObject { 00017 00018 /* This is to indicate that this interface has not been released in 00019 * a final version, and is subject to disappear or be changed. When 00020 * you use an interface marked in this manner, you have to indicate 00021 * your acceptance of this unstable condition by defining the 00022 * UNSTABLE pre-processor symbol (see the Makefile). 00023 * 00024 * Once this marker is removed, an interface cannot be changed ever 00025 * again, neither in syntax (adding/removing methods) or in 00026 * semantics (changing the meaning of methods). 00027 * 00028 * You are allowed to change the name of the interface, if you want, 00029 * because the real identifier of the interface is the IID (defined 00030 * at the bottom). For example, you might create a new version of 00031 * the interface someday and rename this one to IExampleOld. 00032 * 00033 * This is how you can have progress in XPLC: instead of changing 00034 * existing interfaces, you create new ones. A new version of 00035 * IExample could derive from IExampleOld, if you only wanted to add 00036 * some methods, thus making it easy to stay compatible (any code 00037 * that wanted an IExampleOld will work with the new IExample). 00038 */ 00039 UNSTABLE_INTERFACE 00040 00041 public: 00042 /* Here are some of the most important rules for an XPLC interface: 00043 * 00044 * - It can only have public members. 00045 * - Non-method members are not allowed (you cannot have variables). 00046 * - All methods must be pure virtual. 00047 */ 00048 00049 virtual void sayHello() = 0; 00050 }; 00051 00052 /* These numbers are obtained using "uuidgen" or "guidgen.exe". The 00053 * "uuid2cdef.pl" script can be used to fix the formatting of the 00054 * "uuidgen" program. 00055 * 00056 * This is the ultimate identifier for this interface. Changing either 00057 * the syntax or the semantics of an interface without changing this 00058 * identifier would be Bad. 00059 * 00060 * "IID" stands for "Interface ID". This is a normal UUID, there is 00061 * nothing different except the name, but it helps to have some 00062 * context when discussing or documenting things. 00063 */ 00064 DEFINE_IID(IExample, {0x86c3a2d0, 0xe19b, 0x49d0, 00065 {0xb2, 0x84, 0x67, 0xc1, 0x11, 0x4a, 0x9d, 0x79}}); 00066 00067 #endif /* __EXAMPLE_EXAMPLE_H__ */