nx_server_plugin_sdk 1.0 Server Plugin SDK

algorithm.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 "data.h"
6
7 namespace nx::sdk::cloud_storage {
8
9 bool bookmarkMatches(const Bookmark& bookmark, const BookmarkFilter& filter);
10 void sortAndLimitBookmarks(const BookmarkFilter& filter, std::vector<Bookmark>* outBookmarks);
11
12 bool motionMaches(const Motion& motion, const MotionFilter& filter);
13
14 bool objectTrackMatches(const ObjectTrack& objectTrack, const AnalyticsFilter& filter);
15 TimePeriodList sortAndLimitTimePeriods(
16 TimePeriodList periods, SortOrder order, std::optional<int> limit);
17
18 std::vector<uint8_t> fromBase64(const std::string& data);
19 std::string toBase64(const std::vector<uint8_t>& data);
20 std::string toBase64(const uint8_t* data, int size);
21
22 nx::sdk::cloud_storage::IDeviceAgent* findDeviceAgentById(
23 const std::string& id,
24 const std::vector<nx::sdk::Ptr<nx::sdk::cloud_storage::IDeviceAgent>>& devices);
25
26 template<typename T>
27 std::string dumpObjects(const std::vector<T>& objects)
28 {
29 if constexpr (std::is_same_v<T, TimePeriod>)
30 return timePeriodListToJson(objects).dump();
31
32 std::vector<nx::kit::Json> jsons;
33 for (const auto& entry: objects)
34 jsons.push_back(nx::kit::Json(entry));
35
36 return nx::kit::Json(jsons).dump();
37 }
38
39 std::vector<std::string> split(const std::string& original, const std::string& separator);
40
41 } // namespace nx::sdk::cloud_storage
nx::kit::detail::json11::Json
Definition: json.cpp:80
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::cloud_storage::IDeviceAgent
Definition: i_device_agent.h:21
nx::sdk::cloud_storage
Definition: algorithm.cpp:9