ESA JPIP server  0.1
index_manager.h
Go to the documentation of this file.
1 #ifndef _JPEG2000_INDEX_MANAGER_H_
2 #define _JPEG2000_INDEX_MANAGER_H_
3 
4 
5 #include <list>
6 #include "ipc/mutex.h"
7 #include "image_index.h"
8 #include "file_manager.h"
9 
10 
11 namespace jpeg2000
12 {
13  using namespace ipc;
14 
15 
26  {
27  private:
32 
34  list<ImageIndex> index_list;
35 
43  bool UnsafeOpenImage(string &path_image_file, ImageIndex::Ptr *image_index);
44 
51  bool UnsafeCloseImage(const ImageIndex::Ptr& image_index);
52 
53  public:
58  {
59  }
60 
67  bool Init(string root_dir, string cache_dir)
68  {
69  return file_manager_.Init(root_dir, cache_dir) && mutex.Init(false);
70  }
71 
76  {
77  return index_list.begin();
78  }
79 
84  {
85  return index_list.end();
86  }
87 
92  {
93  return file_manager_;
94  }
95 
102  bool OpenImage(string &path_image_file, ImageIndex::Ptr *image_index);
103 
110  bool CloseImage(const ImageIndex::Ptr& image_index);
111 
115  int GetSize() const
116  {
117  return (int)index_list.size();
118  }
119 
120  virtual ~IndexManager()
121  {
122  }
123  };
124 }
125 
126 #endif /* _JPEG2000_INDEX_MANAGER_H_ */
127 
IPC object that offers the functionality of a mutex, implemented by means of the pthread mutex API...
Definition: mutex.h:18
Manages the indexing information of a repository fo images.
Definition: index_manager.h:25
list< ImageIndex > index_list
List of the indexes.
Definition: index_manager.h:34
int GetSize() const
Returns the size of the list.
Definition: index_manager.h:115
ImageIndex::Ptr GetEnd()
Returns a pointer to the last image index.
Definition: index_manager.h:83
bool Init(string root_dir, string cache_dir)
Initializes the object.
Definition: index_manager.h:67
virtual ~IndexManager()
Definition: index_manager.h:120
ImageIndex::Ptr GetBegin()
Returns a pointer to the first image index.
Definition: index_manager.h:75
list< ImageIndex >::iterator Ptr
Pointer of an object of this class.
Definition: image_index.h:118
FileManager file_manager_
File manager.
Definition: index_manager.h:33
IndexManager()
Empty constructor.
Definition: index_manager.h:57
Manages the image files of a repository, allowing read their indexing information, with a caching mechanism for efficiency.
Definition: file_manager.h:17
Mutex mutex
Mutex for the operations with the list.
Definition: index_manager.h:31
FileManager & file_manager()
Returns a reference to the base file manager.
Definition: index_manager.h:91