WvStreams
wvmoniker.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Support for monikers, which are strings that you can pass to a magic
6 * factory to get objects supporting a particular interface, without actually
7 * knowing anything about the constructor for those objects.
8 */
9#ifndef __WVMONIKER_H
10#define __WVMONIKER_H
11
12#include "wvstring.h"
13#include "wvxplc.h"
14
16
17typedef void *WvMonikerCreateFunc(WvStringParm parms, IObject *obj);
18
32{
33protected:
34 WvMonikerBase(const UUID &iid, WvStringParm _id,
35 WvMonikerCreateFunc *func, const bool override = false);
37
38public:
39 WvString id;
41};
42
43
60template <class T>
62{
63public:
64 typedef T *CreateFunc(WvStringParm parms, IObject *obj);
65
66 WvMoniker(WvStringParm _id, CreateFunc *_func, const bool override = false)
67 : WvMonikerBase(XPLC_IID<T>::get(), _id, (WvMonikerCreateFunc *)_func,
68 override)
69 {
70 // this looks pointless, but it ensures that T* can be safely,
71 // automatically downcast to IObject*. That means T is really derived
72 // from IObject, which is very important. The 'for' avoids a
73 // warning.
74 for(IObject *silly = (T *)NULL; silly; )
75 ;
76 };
77};
78
79
89void *wvcreate(const UUID &iid, WvStringParm s, IObject *obj);
90
91
103template <class T>
104inline T *wvcreate(WvStringParm s, IObject *obj = 0)
105{
106 return (T *)(wvcreate(XPLC_IID<T>::get(), s, obj));
107}
108
109
110#endif // __WVMONIKER_H
The basic interface which is included by all other XPLC interfaces and objects.
Definition: IObject.h:65
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition: wvstring.h:94
WvMonikerBase is an auto-registration class for putting things into a WvMonikerRegistry.
Definition: wvmoniker.h:32
A list for holding moniker-prefix to factory-function mappings.
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
Definition: wvmoniker.h:62
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:330
An Interface IDentifier.
Definition: uuid.h:128
The structure underlying UUIDs.
Definition: uuid.h:94