Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

wvmoniker.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  * 
00005  * Support for monikers, which are strings that you can pass to a magic
00006  * factory to get objects supporting a particular interface, without actually
00007  * knowing anything about the constructor for those objects.
00008  */
00009 #ifndef __WVMONIKER_H
00010 #define __WVMONIKER_H
00011 
00012 #include "wvxplc.h"
00013 #include "wvstring.h"
00014 
00015 class WvMonikerRegistry;
00016 
00017 typedef void *WvMonikerCreateFunc(WvStringParm parms,
00018                                   IObject *obj, void *userdata);
00019 
00032 class WvMonikerBase
00033 {
00034 protected:
00035     WvMonikerBase(const UUID &iid, WvStringParm _id,
00036                   WvMonikerCreateFunc *func);
00037     ~WvMonikerBase();
00038     
00039 public:
00040     WvString id;
00041     WvMonikerRegistry *reg;
00042 };
00043 
00044 
00061 template <class T>
00062 class WvMoniker : public WvMonikerBase
00063 {
00064 public:
00065     typedef T *CreateFunc(WvStringParm parms, IObject *obj, void *userdata);
00066     
00067     WvMoniker(WvStringParm _id, CreateFunc *_func)
00068         : WvMonikerBase(XPLC_IID<T>::get(), _id, (WvMonikerCreateFunc *)_func)
00069     { 
00070         // this looks pointless, but it ensures that T* can be safely,
00071         // automatically downcast to IObject*.  That means T is really derived
00072         // from IObject, which is very important. The 'for' avoids a
00073         // warning.
00074         for(IObject *silly = (T *)NULL; silly; )
00075             ;
00076     };
00077 };
00078 
00079 
00089 void *wvcreate(const UUID &iid,
00090                WvStringParm s, IObject *obj = NULL, void *userdata = NULL);
00091 
00092 
00104 template <class T>
00105 inline T *wvcreate(WvStringParm s, IObject *obj = NULL, void *userdata = NULL)
00106 {
00107     return (T *)(wvcreate(XPLC_IID<T>::get(), s, obj, userdata));
00108 }
00109 
00110 
00111 #endif // __WVMONIKER_H

Generated on Sun Jul 10 18:25:52 2005 for WvStreams by  doxygen 1.4.0