EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Index.h
1 #ifndef __INDEX_H__
2 #define __INDEX_H__
3 
4 // tools
5 #include "tools/ToolsConfig.h"
6 
7 // storage
8 #include "storage/NameHash.h"
9 #include "storage/RTree.h"
10 
13 
15 
16 class Index {
17 
18 public:
19 
21  Index();
22 
24  virtual ~Index();
25 
27  enum ReadWrite {
28  ReadOnly,
29  ReadAndWrite
30  };
31 
37  virtual void open(const stdString &filename,
38  ReadWrite readwrite=ReadOnly) = 0;
39 
44  const std::string& getFilename()
45  { return filename; }
46 
51  const std::string& getDirectory()
52  { return dirname; }
53 
58  const stdString &getFullName()
59  { return fullname; }
60 
62  virtual void close() = 0;
63 
65  class Result
66  {
67  public:
68 
70  Result(RTree *tree, const stdString &directory);
71 
73  ~Result();
74 
76  RTree *getRTree() const
77  { return tree; }
78 
80  const stdString &getDirectory() const
81  { return directory; }
82 
83  private:
84 
85  // This class maintains the RTree pointer. Prohibit copy.
86  PROHIBIT_DEFAULT_COPY(Result);
87 
88  RTree *tree;
89  stdString directory;
90  };
91 
101  virtual Result *addChannel(const stdString &channel) = 0;
102 
112  virtual Result *findChannel(const stdString &channel) = 0;
113 
115  class NameIterator {
116 
117  public:
119  virtual ~NameIterator();
120 
122  virtual bool isValid() const = 0;
123 
125  virtual const stdString &getName() const = 0;
126 
130  virtual void next() = 0;
131  };
132 
138  virtual NameIterator *iterator() = 0;
139 
140 protected:
141 
143  PROHIBIT_DEFAULT_COPY(Index);
144 
146  void setFilename(const stdString &full_name);
147 
149  void clearFilename();
150 
151 private:
152 
154  stdString filename;
155 
157  stdString dirname;
158 
160  stdString fullname;
161 };
162 
164 
165 #endif
Name iterator.
Definition: Index.h:115
virtual void next()=0
Get next entry.
RTree * getRTree() const
Definition: Index.h:76
Return value of addChannel() and findChannel()
Definition: Index.h:65
ReadWrite
Modes used for open.
Definition: Index.h:27
virtual NameIterator * iterator()=0
Get NameIterator, located on first channel.
const stdString & getDirectory() const
Definition: Index.h:80
~Result()
Destructor, deletes the RTree pointer.
virtual bool isValid() const =0
virtual void close()=0
Close the index.
virtual ~Index()
Destructor.
Index()
Constructor.
Implements a file-based RTree.
Definition: RTree.h:54
const stdString & getFullName()
Definition: Index.h:58
const std::string & getFilename()
Get the basename.
Definition: Index.h:44
const std::string & getDirectory()
Get the directory.
Definition: Index.h:51
virtual Result * addChannel(const stdString &channel)=0
Add a channel to the index.
virtual void open(const stdString &filename, ReadWrite readwrite=ReadOnly)=0
Open an index.
Base interface for the archiver's indices.
Definition: Index.h:16
Result(RTree *tree, const stdString &directory)
Construct result.
virtual Result * findChannel(const stdString &channel)=0
Obtain the RTree for a channel.
virtual ~NameIterator()
Destructor.
virtual const stdString & getName() const =0