HRCore V1.1.0
A High Resolution Calculation Library
Loading...
Searching...
No Matches
StorageIF.hpp
Go to the documentation of this file.
1
11#ifndef __HRCORE_STORAGEIF__HPP__
12#define __HRCORE_STORAGEIF__HPP__
13
14#include "../HRCore.h"
15
16namespace HRCore {
17
22namespace Storage {
23
28 class Interface {
29 public:
30
32 struct item_t {
33 ival_t* data = nullptr;
34
39 explicit operator bool() const noexcept { return (data != nullptr); }
40 protected:
42 void* appendix = nullptr;
43
45 size_t index = 0;
46 };
47
52 virtual item_t begin() = 0;
53
58 virtual item_t end() = 0;
59
66 virtual item_t next(item_t cur) = 0;
67
74 virtual item_t prev(item_t cur) = 0;
75
81 virtual item_t at(size_t pos) = 0;
82
88 virtual size_t length() = 0;
89
96 virtual bool shrink(size_t len) = 0;
97
105 virtual bool extend(size_t len) = 0;
106
111 virtual Interface* newObject() = 0;
112
118 virtual void delObject(const Interface* ptr) = 0;
119
120 };
121
122}
123}
124
125#endif
A class as a storage interface, pure virtual.
Definition: StorageIF.hpp:28
virtual Interface * newObject()=0
Get a new object of same type.
virtual size_t length()=0
Get the length of storage.
virtual void delObject(const Interface *ptr)=0
Delete a object from newObject()
virtual item_t at(size_t pos)=0
Access to storage[pos].
virtual bool shrink(size_t len)=0
Remove data from the end to shrink the size to a given length.
virtual bool extend(size_t len)=0
Extend the storage to a given length.
virtual item_t next(item_t cur)=0
Get next item.
virtual item_t end()=0
Returns the last item of storage.
virtual item_t begin()=0
Return the first item of storage.
virtual item_t prev(item_t cur)=0
HRCore main namespace, contains all classes.
Definition: LinkedList.hpp:14
Storage item descriptor.
Definition: StorageIF.hpp:32
void * appendix
Store an appendix pointer.
Definition: StorageIF.hpp:42
size_t index
Store the index of data.
Definition: StorageIF.hpp:45