WvStreams
wvtypetraits.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2004 Net Integration Technologies, Inc.
4 *
5 * Contains code you'd rather not think about.
6 */
7#ifndef __WVTYPETRAITS_H
8#define __WVTYPETRAITS_H
9
10#include "wvxplc.h"
11
12template<class T, bool b>
14{
15 static inline void maybe_addref(T* obj)
16 {
17 }
18 static inline void release(T* obj)
19 {
20 delete obj;
21 }
22};
23
24
25template<class T>
26struct WvTraits_Helper<T, true>
27{
28 static inline void maybe_addref(T* obj)
29 {
30 obj->addRef();
31 }
32 static inline void release(T* obj)
33 {
34 if (obj)
35 obj->release();
36 }
37};
38
39
40template<class From>
42{
43 typedef char Yes;
44 struct No { char dummy[2]; };
45 static From* from;
46 static Yes test(IObject*);
47 static No test(...);
48public:
49 static inline void maybe_addref(From* obj)
50 {
51 const bool is_iobject = (sizeof(test(from)) == sizeof(Yes));
53 }
54 static inline void release(From* obj)
55 {
56 const bool is_iobject = (sizeof(test(from)) == sizeof(Yes));
58 }
59};
60
61#endif /* __WVTYPETRAITS_H */
The basic interface which is included by all other XPLC interfaces and objects.
Definition IObject.h:65