CMS 3D CMS Logo

LStoreFile.h
Go to the documentation of this file.
1 #ifndef LSTORE_ADAPTOR_LSTORE_FILE_H
2 #define LSTORE_ADAPTOR_LSTORE_FILE_H
3 
6 #include <string>
7 #include <pthread.h>
8 class LStoreFile : public Storage {
9 public:
10  LStoreFile(void);
11  LStoreFile(void *fd);
12  LStoreFile(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
13  LStoreFile(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
14  ~LStoreFile(void) override;
15 
16  virtual void create(const char *name, bool exclusive = false, int perms = 0666);
17  virtual void create(const std::string &name, bool exclusive = false, int perms = 0666);
18  virtual void open(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
19  virtual void open(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
20 
21  using Storage::position;
22  using Storage::read;
23  using Storage::write;
24 
25  IOSize read(void *into, IOSize n) override;
26  IOSize write(const void *from, IOSize n) override;
27 
28  IOOffset position(IOOffset offset, Relative whence = SET) override;
29  void resize(IOOffset size) override;
30 
31  void close(void) override;
32  virtual void abort(void);
33 
34  class MutexWrapper {
35  public:
36  MutexWrapper(pthread_mutex_t *lock);
37  ~MutexWrapper();
38  pthread_mutex_t *m_lock;
39  };
40 
41  static pthread_mutex_t m_dlopen_lock;
42 
43 private:
44  // functions
45 
46  void loadLibrary();
47  void closeLibrary();
48 
49  //data
50 
51  void *m_fd;
52  bool m_close;
56 
57  // Prototypes for functions
58  // These are data members that are function pointers.
59 
60  int32_t (*redd_init)();
61  int64_t (*redd_read)(void *, char *, int64_t);
62  int32_t (*redd_close)(void *);
63  int64_t (*redd_lseek)(void *, int64_t, uint32_t);
64  void *(*redd_open)(const char *, int32_t, int32_t);
65  int64_t (*redd_write)(void *, const char *, int64_t);
66  int32_t (*redd_term)();
67  int32_t (*redd_errno)();
68  const std::string &(*redd_strerror)();
69 };
70 
71 #endif // LSTORE_ADAPTOR_LSTORE_FILE_H
void loadLibrary()
Definition: LStoreFile.cc:84
int32_t(* redd_errno)()
Definition: LStoreFile.h:67
void * m_library_handle
Definition: LStoreFile.h:54
int64_t(* redd_lseek)(void *, int64_t, uint32_t)
Definition: LStoreFile.h:63
pthread_mutex_t * m_lock
Definition: LStoreFile.h:38
std::string m_name
Definition: LStoreFile.h:53
void close(void) override
Definition: LStoreFile.cc:208
int32_t(* redd_init)()
Definition: LStoreFile.h:60
Relative
Definition: Storage.h:22
int32_t(* redd_term)()
Definition: LStoreFile.h:66
bool m_close
Definition: LStoreFile.h:52
void * m_fd
Definition: LStoreFile.h:51
int64_t(* redd_write)(void *, const char *, int64_t)
Definition: LStoreFile.h:65
MutexWrapper(pthread_mutex_t *lock)
Definition: LStoreFile.cc:284
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:44
virtual IOOffset position(void) const
Definition: Storage.cc:72
void resize(IOOffset size) override
Definition: LStoreFile.cc:278
int read(void)
Definition: IOInput.cc:52
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: LStoreFile.cc:157
virtual void abort(void)
Definition: LStoreFile.cc:226
void closeLibrary()
Definition: LStoreFile.cc:116
virtual IOOffset size(void) const
Definition: Storage.cc:77
int64_t IOOffset
Definition: IOTypes.h:19
bool m_is_loaded
Definition: LStoreFile.h:55
int32_t(* redd_close)(void *)
Definition: LStoreFile.h:62
int64_t(* redd_read)(void *, char *, int64_t)
Definition: LStoreFile.h:61
LStoreFile(void)
Definition: LStoreFile.cc:16
static pthread_mutex_t m_dlopen_lock
Definition: LStoreFile.h:41
virtual void create(const char *name, bool exclusive=false, int perms=0666)
Definition: LStoreFile.cc:141
size_t IOSize
Definition: IOTypes.h:14
IOSize write(const void *from, IOSize n) override
Definition: LStoreFile.cc:247
~LStoreFile(void) override
Definition: LStoreFile.cc:64
fd
Definition: ztee.py:136