nx_server_plugin_sdk 1.0 Server Plugin SDK

test_io_device.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 <string>
6
7 #include <common.h>
8
9 #include <detail/fs_stub.h>
10 #include <storage/third_party_storage.h>
11
12 enum class FileCategory
13 {
14 media,
15 db,
16 infoTxt
17 };
18
19 class TestIODevice:
20 public nx_spl::IODevice,
21 public PluginRefCounter<TestIODevice>
22 {
23 public:
24 TestIODevice(const std::string& name, FileCategory category,
25 int mode, int64_t size = 0, FILE* f = nullptr);
26 ~TestIODevice();
27 public:
28 virtual uint32_t STORAGE_METHOD_CALL write(
29 const void* src,
30 const uint32_t size,
31 int* ecode
32 ) override;
33
34 virtual uint32_t STORAGE_METHOD_CALL read(
35 void* dst,
36 const uint32_t size,
37 int* ecode
38 ) const override;
39
40 virtual int STORAGE_METHOD_CALL getMode() const override;
41
42 virtual uint32_t STORAGE_METHOD_CALL size(int* ecode) const override;
43
44 virtual int STORAGE_METHOD_CALL seek(
45 uint64_t pos,
46 int* ecode
47 ) override;
48
49 public: // plugin interface implementation
50 virtual void* queryInterface(const nxpl::NX_GUID& interfaceID) override;
51
52 virtual int addRef() const override;
53 virtual int releaseRef() const override;
54
55 private:
56 virtual uint32_t readImpl(void* dst, uint32_t size, int* ecode) const;
57 virtual int seekImpl(uint64_t pos, int* ecode);
58
59 protected:
60 const std::string m_sampleFileName;
61
62 private:
63 FileCategory m_category;
64 int m_mode;
65 int64_t m_size;
66 FILE* m_file;
67 mutable int m_camInfoPos;
68 };
PluginRefCounter
Definition: common.h:14
TestIODevice::addRef
virtual int addRef() const override
Increment reference counter.
Definition: test_io_device.cpp:41
TestIODevice::write
virtual uint32_t STORAGE_METHOD_CALL write(const void *src, const uint32_t size, int *ecode) override
Definition: test_io_device.cpp:51
nxpl::NX_GUID
GUID of plugin interface.
Definition: plugin_api.h:26
TestIODevice::seek
virtual int STORAGE_METHOD_CALL seek(uint64_t pos, int *ecode) override
Definition: test_io_device.cpp:110
TestIODevice
Definition: test_io_device.h:19
TestIODevice::releaseRef
virtual int releaseRef() const override
Decrement reference counter.
Definition: test_io_device.cpp:46
TestIODevice::size
virtual uint32_t STORAGE_METHOD_CALL size(int *ecode) const override
Definition: test_io_device.cpp:103
TestIODevice::read
virtual uint32_t STORAGE_METHOD_CALL read(void *dst, const uint32_t size, int *ecode) const override
Definition: test_io_device.cpp:65
TestIODevice::queryInterface
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID) override
Cast to type, specified by interfaceID.
Definition: test_io_device.cpp:25
TestIODevice::getMode
virtual int STORAGE_METHOD_CALL getMode() const override
Definition: test_io_device.cpp:98
nx_spl::IODevice
IO device abstraction.
Definition: third_party_storage.h:73