nx_server_plugin_sdk 1.0 Server Plugin SDK

test_storage.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <functional>
6
7 #include <common.h>
8 #include <vfs.h>
9
10 #include <storage/third_party_storage.h>
11
12 struct FsStubNode;
13
14 class TestStorage:
15 public nx_spl::Storage,
16 public PluginRefCounter<TestStorage>
17 {
18 public:
19 TestStorage(const utils::VfsPair& vfsPair,
20 const std::string& prefix,
21 std::function<void()> onDestroyCb);
22 virtual ~TestStorage();
23
24 virtual int STORAGE_METHOD_CALL isAvailable() const override;
25
26 virtual nx_spl::IODevice* STORAGE_METHOD_CALL open(
27 const char* url,
28 int flags,
29 int* ecode
30 ) const override;
31
32 virtual uint64_t STORAGE_METHOD_CALL getFreeSpace(int* ecode) const override;
33
34 virtual uint64_t STORAGE_METHOD_CALL getTotalSpace(int* ecode) const override;
35
36 virtual int STORAGE_METHOD_CALL getCapabilities() const override;
37
38 virtual void STORAGE_METHOD_CALL removeFile(
39 const char* url,
40 int* ecode
41 ) override;
42
43 virtual void STORAGE_METHOD_CALL removeDir(
44 const char* url,
45 int* ecode
46 ) override;
47
48 virtual void STORAGE_METHOD_CALL renameFile(
49 const char* oldUrl,
50 const char* newUrl,
51 int* ecode
52 ) override;
53
54 virtual nx_spl::FileInfoIterator* STORAGE_METHOD_CALL getFileIterator(
55 const char* dirUrl,
56 int* ecode
57 ) const override;
58
59 virtual int STORAGE_METHOD_CALL fileExists(
60 const char* url,
61 int* ecode
62 ) const override;
63
64 virtual int STORAGE_METHOD_CALL dirExists(
65 const char* url,
66 int* ecode
67 ) const override;
68
69 virtual uint64_t STORAGE_METHOD_CALL fileSize(
70 const char* url,
71 int* ecode
72 ) const override;
73
74 public: // plugin interface implementation
75 virtual void* queryInterface(const nxpl::NX_GUID& interfaceID) override;
76
77 virtual int addRef() const override;
78 virtual int releaseRef() const override;
79
80 private:
81 virtual nx_spl::IODevice* createIODevice(const std::string& name,
82 int category,
83 int flags,
84 int64_t size,
85 int* ecode) const;
86
87 private:
88 utils::VfsPair m_vfsPair;
89 const std::string m_prefix;
90 std::function<void()> m_onDestroyCb;
91 };
TestStorage::removeDir
virtual void STORAGE_METHOD_CALL removeDir(const char *url, int *ecode) override
Definition: test_storage.cpp:179
PluginRefCounter
Definition: common.h:14
nx_spl::FileInfoIterator
File information iterator abstraction.
Definition: third_party_storage.h:138
TestStorage::getFileIterator
virtual nx_spl::FileInfoIterator *STORAGE_METHOD_CALL getFileIterator(const char *dirUrl, int *ecode) const override
Definition: test_storage.cpp:227
TestStorage::getCapabilities
virtual int STORAGE_METHOD_CALL getCapabilities() const override
Definition: test_storage.cpp:166
FsStubNode
Definition: fs_stub.h:15
TestStorage::queryInterface
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID) override
Cast to type, specified by interfaceID.
Definition: test_storage.cpp:279
TestStorage::getFreeSpace
virtual uint64_t STORAGE_METHOD_CALL getFreeSpace(int *ecode) const override
Definition: test_storage.cpp:152
nxpl::NX_GUID
GUID of plugin interface.
Definition: plugin_api.h:26
TestStorage
Definition: test_storage.h:14
TestStorage::fileExists
virtual int STORAGE_METHOD_CALL fileExists(const char *url, int *ecode) const override
Definition: test_storage.cpp:247
TestStorage::fileSize
virtual uint64_t STORAGE_METHOD_CALL fileSize(const char *url, int *ecode) const override
Definition: test_storage.cpp:263
nx_spl::Storage
Storage abstraction.
Definition: third_party_storage.h:155
TestStorage::isAvailable
virtual int STORAGE_METHOD_CALL isAvailable() const override
Definition: test_storage.cpp:70
TestStorage::removeFile
virtual void STORAGE_METHOD_CALL removeFile(const char *url, int *ecode) override
Definition: test_storage.cpp:171
TestStorage::dirExists
virtual int STORAGE_METHOD_CALL dirExists(const char *url, int *ecode) const override
Definition: test_storage.cpp:255
TestStorage::releaseRef
virtual int releaseRef() const override
Decrement reference counter.
Definition: test_storage.cpp:303
TestStorage::renameFile
virtual void STORAGE_METHOD_CALL renameFile(const char *oldUrl, const char *newUrl, int *ecode) override
Definition: test_storage.cpp:187
TestStorage::getTotalSpace
virtual uint64_t STORAGE_METHOD_CALL getTotalSpace(int *ecode) const override
Definition: test_storage.cpp:159
TestStorage::open
virtual nx_spl::IODevice *STORAGE_METHOD_CALL open(const char *url, int flags, int *ecode) const override
Definition: test_storage.cpp:75
utils::VfsPair
Definition: vfs.h:17
nx_spl::IODevice
IO device abstraction.
Definition: third_party_storage.h:73
TestStorage::addRef
virtual int addRef() const override
Increment reference counter.
Definition: test_storage.cpp:298