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 
13 static IUniConfGen *creator(WvStringParm s, IObject *_obj)
14 {
15  return new UniSlowGen(wvcreate<IUniConfGen>(s, _obj));
16 }
17 
18 static WvMoniker<IUniConfGen> reg("slow", creator);
19 
20 
21 UniSlowGen::UniSlowGen(IUniConfGen *inner) : UniFilterGen(inner)
22 {
23  slowcount = 0;
24 }
25 
26 
27 UniSlowGen::~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 
83 void 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