nx_server_plugin_sdk 1.0 Server Plugin SDK

test_storage_factory.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 <mutex>
6 #include <string>
7 #include <unordered_set>
8
9 #include <common.h>
10 #include <url.h>
11 #include <vfs.h>
12
13 #include <storage/third_party_storage.h>
14
15 // {2E2C7A3D-256D-4018-B40E-512D72510BEC}
16 static const nxpl::NX_GUID IID_StorageFactory =
17 { { 0x2e, 0x2c, 0x7a, 0x3d, 0x25, 0x6d, 0x40, 0x18, 0xb4, 0xe, 0x51, 0x2d, 0x72, 0x51, 0xb, 0xec } };
18
19 class TestStorageFactory:
20 public nx_spl::StorageFactory,
21 public PluginRefCounter<TestStorageFactory>
22 {
23 public:
24 virtual const char** STORAGE_METHOD_CALL findAvailable() const override;
25
26 virtual nx_spl::Storage* STORAGE_METHOD_CALL createStorage(
27 const char* url,
28 int* ecode
29 ) override;
30
31 virtual const char* STORAGE_METHOD_CALL storageType() const override;
32
33 virtual const char* lastErrorMessage(int ecode) const override;
34
35 public: // plugin interface implementation
36 virtual void* queryInterface(const nxpl::NX_GUID& interfaceID) override;
37
38 virtual int addRef() const override;
39 virtual int releaseRef() const override;
40
41 private:
42 virtual bool readConfig(const std::string& path, std::string* outContent);
43 virtual nx_spl::Storage* createStorageImpl(const utils::VfsPair& vfsPair, const ::utils::Url&);
44
45 protected:
46 std::unordered_set<std::string> m_storageHosts;
47 std::mutex m_storageHostsMutex;
48 };
PluginRefCounter
Definition: common.h:14
nx_spl::StorageFactory
Storage factory abstraction.
Definition: third_party_storage.h:273
TestStorageFactory::lastErrorMessage
virtual const char * lastErrorMessage(int ecode) const override
Definition: test_storage_factory.cpp:176
TestStorageFactory::findAvailable
virtual const char **STORAGE_METHOD_CALL findAvailable() const override
Definition: test_storage_factory.cpp:68
TestStorageFactory::releaseRef
virtual int releaseRef() const override
Decrement reference counter.
Definition: test_storage_factory.cpp:219
TestStorageFactory
Definition: test_storage_factory.h:19
nxpl::NX_GUID
GUID of plugin interface.
Definition: plugin_api.h:26
nx_spl::Storage
Storage abstraction.
Definition: third_party_storage.h:155
TestStorageFactory::createStorage
virtual nx_spl::Storage *STORAGE_METHOD_CALL createStorage(const char *url, int *ecode) override
Definition: test_storage_factory.cpp:83
TestStorageFactory::queryInterface
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID) override
Cast to type, specified by interfaceID.
Definition: test_storage_factory.cpp:195
utils::VfsPair
Definition: vfs.h:17
TestStorageFactory::storageType
virtual const char *STORAGE_METHOD_CALL storageType() const override
Definition: test_storage_factory.cpp:171
TestStorageFactory::addRef
virtual int addRef() const override
Increment reference counter.
Definition: test_storage_factory.cpp:214