The following code fragment shows a typical use of the e4_StorageVisitor class:
The storage visitor sv is initialized to visit all storages that are currently open. We iterate over each storage in turn, and when we reach the storage s, we print a message to stderr.e4_Storage s("mystorage", E4_METAKIT); if (!s.IsValid()) {...} ... e4_StorageVisitor sv(); e4_Storage cs; while (sv.CurrentStorageAndAdvance(cs)) { if (!cs.IsValid()) {...} if (cs == s) { fprintf(stderr, "Found our storage, %s %s\n", cs.GetName(), s.GetName()); } }
The following methods are provided by the e4_StorageVisitor class:
e4_StorageVisitor() | Default constructor. Creates an instance of e4_StorageVisitor that is initialized and ready to visit all currently open storages in an implementation dependent manner. It is undefined and implementation dependent whether the visitor will see storages that are opened after it was created. |
e4_StorageVisitor(const e4_StorageVisitor &referrer) | Copy constructor. Creates an instance of e4_StorageVisitor that is initialized to start visiting storages from the storage currently visited by referrer. The new instance and referrer will visit all remaining subsequent storages in the same order. |
~e4_StorageVisitor() | Destructor. Destroys this instance and decrements the reference count on the currently visited storage, if any. |
e4_StorageVisitor &operator=(const e4_StorageVisitor &referrer) | Assignment operator. After the assignment, this instance will visit storages in the same order as referrer. |
bool operator==(const e4_StorageVisitor &comp) | Returns true if comp refers to the same instance of e4_StorageVisitor as this instance. |
bool operator!=(const e4_StorageVisitor &comp) | Returns true if comp does not refer to the same instance of e4_StorageVisitor as this instance. |
bool IsDone() | Returns true if this instance has no more storages to visit. |
bool IsValid() | Returns true if this instance is not valid. An e4_Storage instance can become invalid if the storage it currently is visiting is closed. In that case the e4_Storage class cannot continue to the next instance with the NextStorage method and cannot retrieve the current instance being visited with the CurrentStorage method. |
bool CurrentStorage(e4_Storage &s) | Returns true if the current storage being visited is successfully retrieved in s. You can call this method any number of times to retrieve the currently visited storage; it does not advance the visitor to the next storage in line. |
bool NextStorage(e4_Storage &s) | Returns true if the visitor successfully advanced to the next storage to be visited and if that storage was successfully retrieved in s. Each time you call this method, the visitor advances to the next storage and returns it in s. |
bool CurrentStorageAndAdvance(e4_Storage &s) | Returns true if the current storage being visited is successfully retrieved in s and the visitor is successfully advanced to the next storage to be visited. Each time this method is called, the currently visited storage is returned in s and the visitor is advanced to the next storage to be visited. |