Main Page
Namespaces
Classes
Files
File List
File Members
src
MessageVariable.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) 2014 by Ralf Kaestner *
3
* ralf.kaestner@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the Lesser GNU General Public License as published by*
7
* the Free Software Foundation; either version 3 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* Lesser GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the Lesser GNU General Public License *
16
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17
******************************************************************************/
18
19
#include "
variant_topic_tools/Exceptions.h
"
20
#include "
variant_topic_tools/MessageVariable.h
"
21
22
namespace
variant_topic_tools
{
23
24
/*****************************************************************************/
25
/* Constructors and Destructor */
26
/*****************************************************************************/
27
28
MessageVariable::MessageVariable
() {
29
}
30
31
MessageVariable::MessageVariable
(
const
std::string& name,
const
DataType
&
32
type) {
33
impl
.reset(
new
Impl
(name, type));
34
}
35
36
MessageVariable::MessageVariable
(
const
MessageVariable
& src) :
37
MessageMember
(src) {
38
}
39
40
MessageVariable::MessageVariable
(
const
MessageMember
& src) :
41
MessageMember
(src) {
42
if
(
impl
)
43
BOOST_ASSERT(boost::dynamic_pointer_cast<MessageVariable::Impl>(
impl
));
44
}
45
46
MessageVariable::~MessageVariable
() {
47
}
48
49
MessageVariable::Impl::Impl
(
const
std::string& name,
const
DataType
& type) :
50
MessageMember
::
Impl
(name),
51
type(type) {
52
if
(!type.
isValid
())
53
throw
InvalidDataTypeException
();
54
}
55
56
MessageVariable::Impl::~Impl
() {
57
}
58
59
/*****************************************************************************/
60
/* Accessors */
61
/*****************************************************************************/
62
63
const
DataType
&
MessageVariable::Impl::getType
()
const
{
64
return
type
;
65
}
66
67
/*****************************************************************************/
68
/* Methods */
69
/*****************************************************************************/
70
71
void
MessageVariable::Impl::write
(std::ostream& stream)
const
{
72
stream <<
type
<<
" "
<<
name
;
73
}
74
75
}
variant_topic_tools
Definition:
ArrayDataType.h:29
variant_topic_tools::MessageVariable::Impl::type
DataType type
The data type of this message variable.
Definition:
MessageVariable.h:80
variant_topic_tools::MessageVariable::MessageVariable
MessageVariable()
Default constructor.
Definition:
MessageVariable.cpp:28
variant_topic_tools::InvalidDataTypeException
Exception thrown in case of an invalid data type.
Definition:
Exceptions.h:51
variant_topic_tools::MessageVariable::Impl
Message variable implementation.
Definition:
MessageVariable.h:59
variant_topic_tools::MessageMember::Impl::name
std::string name
The name of this message member.
Definition:
MessageMember.h:100
variant_topic_tools::MessageVariable::Impl::getType
const DataType & getType() const
Retrieve the type of this message member (implementation)
Definition:
MessageVariable.cpp:63
variant_topic_tools::MessageVariable::Impl::Impl
Impl(const std::string &name, const DataType &type)
Constructor.
Definition:
MessageVariable.cpp:49
variant_topic_tools::MessageMember::impl
ImplPtr impl
The message member's implementation.
Definition:
MessageMember.h:114
variant_topic_tools::DataType
Data type.
Definition:
DataType.h:36
variant_topic_tools::DataType::isValid
bool isValid() const
True, if this data type is valid.
Definition:
DataType.cpp:133
variant_topic_tools::MessageMember
Message member.
Definition:
MessageMember.h:31
Exceptions.h
Header file defining exceptions for the variant topic tools.
variant_topic_tools::MessageVariable::Impl::write
void write(std::ostream &stream) const
Write the message member to a stream (implementation)
Definition:
MessageVariable.cpp:71
variant_topic_tools::MessageVariable::Impl::~Impl
virtual ~Impl()
Destructor.
Definition:
MessageVariable.cpp:56
variant_topic_tools::MessageVariable::~MessageVariable
~MessageVariable()
Destructor.
Definition:
MessageVariable.cpp:46
variant_topic_tools::MessageVariable
Variable message member.
Definition:
MessageVariable.h:34
MessageVariable.h
Header file providing the MessageVariable class interface.
variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49