nx_server_plugin_sdk 1.0 Server Plugin SDK

data_list.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 <vector>
6
7 namespace nx::sdk::cloud_storage {
8
9 template<typename Data>
10 class DataList
11 {
12 protected:
13 DataList(std::vector<Data> data):
14 m_data(std::move(data)),
15 m_it(m_data.cbegin())
16 {
17 }
18
19 void goToBeginning() const
20 {
21 m_it = m_data.cbegin();
22 }
23
24 void next() const
25 {
26 if (m_it != m_data.cend())
27 ++m_it;
28 }
29
30 bool atEnd() const
31 {
32 return m_it == m_data.cend();
33 }
34
35 const Data* get() const
36 {
37 if (atEnd())
38 return nullptr;
39
40 return &(*m_it);
41 }
42
43 private:
44 std::vector<Data> m_data;
45 mutable typename std::vector<Data>::const_iterator m_it;
46 };
47
48 } // namespace nx::sdk::cloud_storage
nx::sdk::cloud_storage
Definition: algorithm.cpp:9
nx::sdk::cloud_storage::DataList
Definition: data_list.h:10