WvStreams
include/uniretrygen.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
4 *
5 * A UniConfGen that reconnects to an inner generator whenever the inner
6 * generator is no longer OK.
7 */
8#ifndef __UNIRETRYGEN_H
9#define __UNIRETRYGEN_H
10
11#include "unifiltergen.h"
12#include "wvtimeutils.h"
13#include "wvlog.h"
14
41class UniRetryGen : public UniFilterGen
42{
43public:
44
45 typedef wv::function<void(UniRetryGen&)> ReconnectCallback;
46
47private:
48
49 WvLog log;
50
51 WvString moniker;
52
53 ReconnectCallback reconnect_callback;
54
55 time_t retry_interval_ms;
56 WvTime next_reconnect_attempt;
57
58 void maybe_disconnect();
59 void maybe_reconnect();
60
61public:
62
64 ReconnectCallback _reconect_callback = ReconnectCallback(),
65 time_t _retry_internal_ms = 5000);
66
67 /***** Overridden methods *****/
68
69 virtual void commit();
70 virtual bool refresh();
71 virtual void prefetch(const UniConfKey &key, bool recursive);
72 virtual void flush_buffers() { }
73 virtual WvString get(const UniConfKey &key);
74 virtual void set(const UniConfKey &key, WvStringParm value);
75 virtual bool exists(const UniConfKey &key);
76 virtual bool haschildren(const UniConfKey &key);
77 virtual bool isok();
78 virtual Iter *iterator(const UniConfKey &key);
79 virtual Iter *recursiveiterator(const UniConfKey &key);
80};
81
82#endif //__UNIRETRYGEN_H
An abstract iterator over keys and values in a generator.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
A UniConfGen that delegates all requests to an inner generator.
A UniConfGen that reconnects to an inner generator specified by a moniker whenever the inner generato...
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
virtual void prefetch(const UniConfKey &key, bool recursive)
Indicate that we will eventually be interested in doing get(), haschildren(), or other "get-like" ope...
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
virtual void commit()
Commits any changes.
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
virtual bool refresh()
Refreshes information about a key recursively.
virtual void flush_buffers()
Flushes any commitment/notification buffers .
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 Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
virtual bool isok()
Determines if the generator is usable and working properly.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
WvString is an implementation of a simple and efficient printable-string class.
Based on (and interchangeable with) struct timeval.