00001
00002
00003
00004
00005
00006
00007 #include "unislowgen.h"
00008 #include "wvmoniker.h"
00009 #include <unistd.h>
00010
00011
00012 static IUniConfGen *creator(WvStringParm s)
00013 {
00014 return new UniSlowGen(wvcreate<IUniConfGen>(s));
00015 }
00016
00017 static WvMoniker<IUniConfGen> reg("slow", creator);
00018
00019
00020 UniSlowGen::UniSlowGen(IUniConfGen *inner) : UniFilterGen(inner)
00021 {
00022 slowcount = 0;
00023 }
00024
00025
00026 UniSlowGen::~UniSlowGen()
00027 {
00028 fprintf(stderr, "%p: UniSlowGen: ran a total of %d slow operations.\n",
00029 this, how_slow());
00030 }
00031
00032
00033 void UniSlowGen::commit()
00034 {
00035 be_slow("commit()");
00036 UniFilterGen::commit();
00037 }
00038
00039
00040 bool UniSlowGen::refresh()
00041 {
00042 be_slow("refresh()");
00043 return UniFilterGen::refresh();
00044 }
00045
00046
00047 WvString UniSlowGen::get(const UniConfKey &key)
00048 {
00049 be_slow("get(%s)", key);
00050 return UniFilterGen::get(key);
00051 }
00052
00053
00054 bool UniSlowGen::exists(const UniConfKey &key)
00055 {
00056 be_slow("exists(%s)", key);
00057 return UniFilterGen::exists(key);
00058 }
00059
00060
00061 bool UniSlowGen::haschildren(const UniConfKey &key)
00062 {
00063 be_slow("haschildren(%s)", key);
00064 return UniFilterGen::haschildren(key);
00065 }
00066
00067
00068 UniConfGen::Iter *UniSlowGen::iterator(const UniConfKey &key)
00069 {
00070 be_slow("iterator(%s)", key);
00071 return UniFilterGen::iterator(key);
00072 }
00073
00074
00075 UniConfGen::Iter *UniSlowGen::recursiveiterator(const UniConfKey &key)
00076 {
00077 be_slow("recursiveiterator(%s)", key);
00078 return UniFilterGen::recursiveiterator(key);
00079 }
00080
00081
00082 void UniSlowGen::be_slow(WvStringParm what)
00083 {
00084 fprintf(stderr, "%p: UniSlowGen: slow operation: %s\n",
00085 this, what.cstr());
00086
00087 slowcount++;
00088 }
00089
00090