wvxplc.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
#ifndef __WVXPLC_H
00008
#define __WVXPLC_H
00009
00010
#if HAS_XPLC
00011
00012
#include <xplc/xplc.h>
00013
#include <xplc/utils.h>
00014
#include <xplc/IServiceManager.h>
00015
00016
#else // not HAS_XPLC, so we'll fake it (badly)
00017
00018
#include <string.h>
00019
00020 struct XUUID
00021 {
00022 unsigned int a;
00023 unsigned short b,
c;
00024 unsigned char d[8];
00025
00026 bool operator== (
const XUUID &other)
const
00027
{
return !memcmp(
this, &other,
sizeof(*
this)); }
00028 };
00029
00030
template<
class T>
00031 struct XIID {
00032 };
00033
00034 #define DEFINE_XIID(iface, u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11) \
00035
static const XUUID iface##_XIID = u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11; \
00036
template<> \
00037
struct XIID<iface> { \
00038
static const XUUID &get() { \
00039
return iface##_XIID; \
00040
} \
00041
}
00042
00043
00044 class IObject
00045 {
00046
public:
00047 virtual ~IObject() { };
00048
00049
virtual unsigned int addRef() = 0;
00050
virtual unsigned int release() = 0;
00051 };
00052
00053
DEFINE_XIID(
IObject, {0x12345678, 0xb653, 0x43d7,
00054 {0xb0, 0x56, 0x8b, 0x9d, 0xde, 0x9a, 0xbe, 0x9d}});
00055
00056
00057
00058
template<
class T>
00059 class GenericComponent :
public T
00060 {
00061
private:
00062
unsigned refcount;
00063
00064
public:
00065 GenericComponent() { refcount = 0; }
00066
00067 virtual unsigned int addRef()
00068 {
return ++refcount; }
00069
00070 virtual unsigned int release()
00071 {
00072
if (--refcount)
00073
return refcount;
00074
00075 refcount = 1;
00076
delete this;
00077
return 0;
00078 }
00079 };
00080
00081
template<
class T,
class T2>
00082 T *
mutate(T2 *x)
00083 {
00084
return (
T *)(
void *)x;
00085 }
00086
00087 #define XUUID_MAP_BEGIN(name)
00088 #define XUUID_MAP_ENTRY(name)
00089 #define XUUID_MAP_END
00090
00091
#endif
00092
00093
#endif // __WVXPLC_H
Generated on Tue Oct 5 01:09:21 2004 for WvStreams by
1.3.7