WvStreams
unislowgen.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
4 *
5 * A UniConfGen that makes everything slow. See unislowgen.h.
6 */
7#include "unislowgen.h"
8#include "wvmoniker.h"
9#ifndef _MSC_VER // FIXME:WLACH Is unistd even needed here?!
10#include <unistd.h>
11#endif
12
13static IUniConfGen *creator(WvStringParm s, IObject *_obj)
14{
15 return new UniSlowGen(wvcreate<IUniConfGen>(s, _obj));
16}
17
18static WvMoniker<IUniConfGen> reg("slow", creator);
19
20
21UniSlowGen::UniSlowGen(IUniConfGen *inner) : UniFilterGen(inner)
22{
23 slowcount = 0;
24}
25
26
27UniSlowGen::~UniSlowGen()
28{
29 fprintf(stderr, "%p: UniSlowGen: ran a total of %d slow operations.\n",
30 this, how_slow());
31}
32
33
35{
36 be_slow("commit()");
38}
39
40
42{
43 be_slow("refresh()");
44 return UniFilterGen::refresh();
45}
46
47
49{
50 be_slow("get(%s)", key);
51 return UniFilterGen::get(key);
52}
53
54
56{
57 be_slow("exists(%s)", key);
58 return UniFilterGen::exists(key);
59}
60
61
63{
64 be_slow("haschildren(%s)", key);
65 return UniFilterGen::haschildren(key);
66}
67
68
70{
71 be_slow("iterator(%s)", key);
72 return UniFilterGen::iterator(key);
73}
74
75
77{
78 be_slow("recursiveiterator(%s)", key);
80}
81
82
83void UniSlowGen::be_slow(WvStringParm what)
84{
85 fprintf(stderr, "%p: UniSlowGen: slow operation: %s\n",
86 this, what.cstr());
87 // sleep(1);
88 slowcount++;
89}
90
91
The basic interface which is included by all other XPLC interfaces and objects.
Definition IObject.h:65
An abstract data container that backs a UniConf tree.
Definition uniconfgen.h:40
An abstract iterator over keys and values in a generator.
Definition uniconfgen.h:324
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition uniconfkey.h:39
A UniConfGen that delegates all requests to an inner generator.
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
virtual bool refresh()
Refreshes information about a key recursively.
virtual void commit()
Commits any changes.
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
A UniConfGen that counts all "potentially synchronous" (ie.
Definition unislowgen.h:28
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
Definition unislowgen.cc:48
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
Definition unislowgen.cc:76
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
Definition unislowgen.cc:55
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
Definition unislowgen.cc:69
virtual bool refresh()
Refreshes information about a key recursively.
Definition unislowgen.cc:41
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
Definition unislowgen.cc:62
virtual void commit()
Commits any changes.
Definition unislowgen.cc:34
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
Definition wvstring.h:94
const char * cstr() const
return a (const char *) for this string.
Definition wvstring.h:267
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