EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
ListIndex.h
1 // -*- c++ -*-
2 
3 #ifndef __LIST_INDEX_H__
4 #define __LIST_INDEX_H__
5 
6 // tools
7 #include "tools/AutoPtr.h"
8 
9 // storage
10 #include "storage/Index.h"
11 
14 
52 class ListIndex : public Index {
53 
54 public:
55 
57  ~ListIndex();
58 
66  virtual void open(const std::string& filename, ReadWrite readwrite=ReadOnly);
67 
69  virtual void close();
70 
72  virtual Result* addChannel(const std::string& channel);
73 
75  virtual Result* findChannel(const std::string& channel);
76 
78  virtual NameIterator* iterator();
79 
80 private:
81 
82  stdString filename;
83 
84  // List of all the sub-archives.
85  // Whenever one is opened because we look
86  // for a channel in one or because we list
87  // all channels, it stays open for performance.
88  // NOTE: If this ever changes, those indices which
89  // returned an RTree * must be kept open until this
90  // ListIndex is removed.
91  // Tried AutoPtr<IndexFile>, but the SubArchInfo is used
92  // in a stdList, which requires several copy constructor
93  // calls of SubArchInfo, and maintaining the index * myself
94  // seemed easier.
95  class SubArchInfo
96  {
97  public:
98 
100  SubArchInfo(stdString name) : name(name), index(0) {}
101 
103  const std::string& getName() const
104  { return name; }
105 
107  Index *openIndex();
108 
110  void closeIndex();
111 
112  private:
113  std::string name;
114  Index *index;
115  };
116 
117  stdList<SubArchInfo> sub_archs;
118 
119  // List of all names w/ iterator
120  stdList<stdString> names;
121 
122  // helper for AVLTree::traverse
123  static void name_traverser(const stdString &name, void *self);
124 
125  void collectNames();
126 };
127 
129 
130 #endif
Name iterator.
Definition: Index.h:115
Return value of addChannel() and findChannel()
Definition: Index.h:65
ReadWrite
Modes used for open.
Definition: Index.h:27
~ListIndex()
Destructor.
virtual void open(const std::string &filename, ReadWrite readwrite=ReadOnly)
Open the index.
virtual Result * findChannel(const std::string &channel)
Returns result of the specified channel.
Index based on list of sub-archives.
Definition: ListIndex.h:52
virtual void close()
Closes the index.
virtual Result * addChannel(const std::string &channel)
Adds channel.
Base interface for the archiver&#39;s indices.
Definition: Index.h:16
virtual NameIterator * iterator()
Returns iterator.