-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathICollectionSchemeList.h
93 lines (80 loc) · 3.22 KB
/
ICollectionSchemeList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "ICollectionScheme.h"
#include <string>
#include <vector>
namespace Aws
{
namespace IoTFleetWise
{
using ICollectionSchemePtr = std::shared_ptr<ICollectionScheme>;
/**
* @brief ICollectionSchemeList is used to exchange a list of collection collectionSchemes from
* Schema to CollectionSchemeManagement.
*
* This list of collection collectionSchemes will arrive as a binary proto of type
* collectionSchemes.proto in a callback function running in the context of an Aws IoT
* MQTT callback. Schema will lazily pack this this binary proto into
* this class, and expose a getter function which will lightly de-serialize the
* proto and return an array of ICollectionSchemePtr.
*
* The reason this abstract interface exists is because we do not want to do any
* de-serialization in Aws IoT Core MQTT callbacks.
*/
class ICollectionSchemeList
{
public:
/**
* @brief Parses the protobuffer data and builds a vector of validated CollectionSchemes. These
* collectionSchemes are validated
*
* @return True if success, false if failure. On failure, no collectionSchemes inside will be usable
*/
virtual bool build() = 0;
/**
* @brief Checks if the data inside this message has been parsed using the build function.
*
* @return True if data is ready to be read, false if otherwise. If this is false after the message has been built,
* it means the data is corrupted and this message cannot be used
*/
virtual bool isReady() const = 0;
/**
* @brief De-serialize the collectionSchemes.proto proto and returns an array of ICollectionSchemePtrs contained in
* the underlying collectionSchemes.proto object.
*
* @return An array of built ICollectionSchemePtrs ready to be used CollectionSchemeManagement. Returns an empty
* array in case of an error.
*/
virtual const std::vector<ICollectionSchemePtr> &getCollectionSchemes() const = 0;
/**
* @brief Used by the AWS IoT MQTT callback to copy data received from Cloud into this object without any further
* processing to minimize time spent in callback context.
*
* @param inputBuffer Byte array of raw protobuffer data for a collectionSchemes.proto type binary blob
* @param size Size of the data buffer
*
* @return True if successfully copied, false if failure to copy data.
*/
virtual bool copyData( const std::uint8_t *inputBuffer, const size_t size ) = 0;
/**
* @brief This function returns mProtoBinaryData majorly used for persistent
* storage
*
* @return binary data in a vector
*/
virtual const std::vector<uint8_t> &getData() const = 0;
virtual ~ICollectionSchemeList() = default;
};
using ICollectionSchemeListPtr = std::shared_ptr<ICollectionSchemeList>;
/**
* @brief Interface for components interested in the currently active collection schemes. Used to prepare senders based
* on campaign data before the data is collected and selected for the upload.
*
*/
struct ActiveCollectionSchemes
{
std::vector<ICollectionSchemePtr> activeCollectionSchemes;
};
} // namespace IoTFleetWise
} // namespace Aws