OpenASIP 2.2
Loading...
Searching...
No Matches
ProgramAnnotation.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file ProgramAnnotation.cc
26 *
27 * Implementation of ProgramAnnotation class.
28 *
29 * @author Pekka Jääskeläinen 2006,2014 (pekka.jaaskelainen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34#include "ProgramAnnotation.hh"
35#include "Conversion.hh"
36#include "InstructionElement.hh"
37
38namespace TTAProgram {
39
40/////////////////////////////////////////////////////////////////////////////
41// ProgramAnnotation
42/////////////////////////////////////////////////////////////////////////////
43
44/**
45 * Constructor.
46 *
47 * @note Exceeding the maximum annotation length of TPEF leads
48 * to an assertion!
49 *
50 * @param id The id of the annotation (a 24-bit value).
51 * @param data The payload data as a string.
52 */
53ProgramAnnotation::ProgramAnnotation(Id id, const std::string& data) :
54 id_(id) {
55 assert(data.length() <=
57 setStringValue(data);
58}
59
61 id_(id) {
62 setIntValue(value);
63}
64
65/**
66 * Constructor.
67 *
68 * @param id The id of the annotation (a 24-bit value).
69 * @param data The payload data as a byte vector.
70 */
72 Id id, const std::vector<Byte>& payload) :
73 id_(id), payload_(payload) {
74 assert(payload.size() <=
76}
77
78/**
79 * Destructor.
80 */
83
84/**
85 * The payload data as a std::string.
86 *
87 * @returns The data as a std::string.
88 */
89std::string
91 return std::string(payload_.begin(), payload_.end());
92}
93
94int
98
99void
101 std::string data = Conversion::toString(value);
102 payload_ = std::vector<Byte>(data.begin(), data.end());
103}
104
105/**
106 * Returns the id of the annotation.
107 *
108 * @return the id of the annotation.
109 */
112 return id_;
113}
114
115/**
116 * Return the payload data as a non-mutable char vector.
117 *
118 * @return The payload data.
119 */
120const std::vector<Byte>&
122 return payload_;
123}
124
125} // namespace TTAProgram
#define assert(condition)
static std::string toString(const T &source)
static int toInt(const T &source)
static const size_t MAX_ANNOTATION_BYTES
Maximum number of bytes that annotation may contain.
const std::vector< Byte > & payload() const
ProgramAnnotation::Id id() const
void setStringValue(const std::string &data)
Id
the ID in TPEF is 24 bits, here enum
std::vector< Byte > payload_
the payload data