WvStreams
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 
41 class UniRetryGen : public UniFilterGen
42 {
43 public:
44 
45  typedef wv::function<void(UniRetryGen&)> ReconnectCallback;
46 
47 private:
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 
61 public:
62 
63  UniRetryGen(WvStringParm _moniker,
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
UniRetryGen::flush_buffers
virtual void flush_buffers()
Flushes any commitment/notification buffers .
Definition: uniretrygen.h:72
UniRetryGen
A UniConfGen that reconnects to an inner generator specified by a moniker whenever the inner generato...
Definition: uniretrygen.h:41
UniRetryGen::refresh
virtual bool refresh()
Refreshes information about a key recursively.
Definition: uniretrygen.cc:135
UniRetryGen::exists
virtual bool exists(const UniConfKey &key)
Without fetching its value, returns true if a key exists.
Definition: uniretrygen.cc:200
WvTime
Based on (and interchangeable with) struct timeval.
Definition: wvtimeutils.h:17
UniRetryGen::get
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
Definition: uniretrygen.cc:162
UniRetryGen::set
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
Definition: uniretrygen.cc:189
UniRetryGen::commit
virtual void commit()
Commits any changes.
Definition: uniretrygen.cc:124
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
UniRetryGen::isok
virtual bool isok()
Determines if the generator is usable and working properly.
Definition: uniretrygen.cc:250
UniConfKey
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition: uniconfkey.h:38
UniRetryGen::haschildren
virtual bool haschildren(const UniConfKey &key)
Returns true if a key has children.
Definition: uniretrygen.cc:234
UniRetryGen::iterator
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
Definition: uniretrygen.cc:262
UniRetryGen::prefetch
virtual void prefetch(const UniConfKey &key, bool recursive)
Indicate that we will eventually be interested in doing get(), haschildren(), or other "get-like" ope...
Definition: uniretrygen.cc:151
UniRetryGen::recursiveiterator
virtual Iter * recursiveiterator(const UniConfKey &key)
Like iterator(), but the returned iterator is recursive, that is, it will return children of the imme...
Definition: uniretrygen.cc:278
UniFilterGen
A UniConfGen that delegates all requests to an inner generator.
Definition: unifiltergen.h:17