-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContent.h
120 lines (107 loc) · 4.44 KB
/
Content.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**
* @file Content.h
* @author Felix Schuelke (flxscode@gmail.com)
* @brief
* @version 0.1
* @date 2024-08-18
*
* @copyright * Copyright (C) 2024 Felix Schuelke
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef CONTENT_H
#define CONTENT_H
#ifdef ARDUINO
#include <Arduino.h> // include Arduino-Library for platformIO-build
#else
#include <mockArduino.h>
using namespace arduinoMocking;
#include <cstring>
#endif
/**
* @author Felix Schuelke
* @brief The cascading of processing information and the rules applied to it lead to the concept of content- and representation.
* In every iteration, an information is processed and the rules of the next level, closer to the physical layer are applied to it,
* the information closer to the format the service is able to process is called Content.
* Conversely, the format, the information has after applying the rules of the next level closer to "Layer-0" is called representation.
* @tparam content_type defines the type for storing the information (content) itself
* @tparam representation_type defines the type the information (content) is represented for the next processing-level
*/
template<typename content_type, typename representation_type>
class Content {
public:
/**
* @brief Construct a new Content object from an instance from type content_type (content itself)
*
* @param content information (content itself) of type content_type
*/
Content(content_type content) : content(content) {}
/**
* @brief Construct a new Content object from it's representation from type representation_type
*
* @param representation representation of the information (content) from type representation_type
*/
Content(representation_type representation) : representation(representation) {}
/**
* @brief Get the address of the informations representation of type representation-type
*
* @return representation_type* pointer to the informations representation
*/
representation_type* get_representation() {
return &representation;
}
/**
* @brief Get the address of the informations content of type content_type
*
* @return content_type*
*/
content_type* get_content() {
return &content;
}
/**
* @brief Representation and Content of the object are existent (not default)
*
* @return true Representation and Content are not default
* @return false Representation or Content do not exist (only defaultvalues)
*/
bool isValid(){
return ((content!=content_type()) & (representation!=representation_type()));
};
protected:
/// @brief Content of an information (view on information (content) closer to Service-Layer)
content_type content;
/// @brief Representation of an information (view on information (content) closer to physical layer)
representation_type representation;
// Convert the representation-attribute to the content-attribute,
// the function has to be called in the constructor of the derived class
/**
* @brief
* Defines the mapping from Representation to Content.
* Convert the class-attribute "representation" to the class-attribute "content".
* (has to be defined in derived class)
* (has to be called in the constructor of the derived class)
*
*/
virtual void rep_to_content() = 0;
/**
* @brief
* Defines the mapping from Content to Representation.
* Convert the class-attribute "content"to the class-attribute "representation" .
* (has to be defined in derived class)
* (has to be called in the constructor of the derived class)
*
*/
virtual void content_to_rep() = 0;
};
#endif // CONTENT_H