8#include "wvmonikerregistry.h"
12#include "wvscatterhash.h"
15# define DEBUGLOG(fmt, args...) fprintf(stderr, fmt, ## args)
18# define DEBUGLOG(fmt, args...)
25static unsigned WvHash(
const UUID &_uuid)
28 unsigned int *uuid = (
unsigned int *)&_uuid;
29 int max =
sizeof(
UUID)/
sizeof(*uuid);
31 for (
int count = 0; count < max; count++)
39static WvMonikerRegistryDict *regs;
43WvMonikerRegistry::WvMonikerRegistry(
const UUID &iid)
46 DEBUGLOG(
"WvMonikerRegistry creating.\n");
51WvMonikerRegistry::~WvMonikerRegistry()
53 DEBUGLOG(
"WvMonikerRegistry destroying.\n");
57void WvMonikerRegistry::add(
WvStringParm id, WvMonikerCreateFunc *func,
60 DEBUGLOG(
"WvMonikerRegistry register(%s).\n",
id.cstr());
62 RegistrationList::Iter i(list);
63 for (i.rewind(); i.next(); )
64 assert(i.ptr()->id !=
id);
66 list.prepend(
new Registration(
id, func),
true);
72 DEBUGLOG(
"WvMonikerRegistry unregister(%s).\n",
id.cstr());
73 RegistrationList::Iter i(list);
74 for (i.rewind(); i.next(); )
76 if (i.ptr()->id ==
id) {
92 char *cptr = strchr(s.edit(),
':');
98 DEBUGLOG(
"WvMonikerRegistry create object ('%s' '%s').\n", s.cstr(), cptr);
100 RegistrationList::Iter i(list);
101 for (i.rewind(); i.next(); )
103 if (i.ptr()->id == s)
104 return i.ptr()->func(cptr, obj);
113 DEBUGLOG(
"WvMonikerRegistry find_reg.\n");
116 regs =
new WvMonikerRegistryDict(10);
124 regs->add(reg,
true);
133IObject *WvMonikerRegistry::getInterface(
const UUID &uuid)
136 if (uuid.equals(IObject_IID))
149unsigned int WvMonikerRegistry::addRef()
151 DEBUGLOG(
"WvMonikerRegistry addRef.\n");
156unsigned int WvMonikerRegistry::release()
158 DEBUGLOG(
"WvMonikerRegistry release.\n");
184 WvMonikerCreateFunc *func,
const bool override)
187 DEBUGLOG(
"WvMoniker creating(%s).\n",
id.cstr());
188 reg = WvMonikerRegistry::find_reg(iid);
190 reg->add(
id, func,
override);
194WvMonikerBase::~WvMonikerBase()
196 DEBUGLOG(
"WvMoniker destroying(%s).\n",
id.cstr());
207 assert(!moniker.
isnull());
212 void *ret = reg->create(moniker, obj);
The basic interface which is included by all other XPLC interfaces and objects.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
bool isnull() const
returns true if this string is null
A list for holding moniker-prefix to factory-function mappings.
WvString is an implementation of a simple and efficient printable-string class.
The structure underlying UUIDs.
char * trim_string(char *string)
Trims whitespace from the beginning and end of the character string, including carriage return / line...