MessageVariable.h
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 
23 #ifndef VARIANT_TOPIC_TOOLS_MESSAGE_VARIABLE_H
24 #define VARIANT_TOPIC_TOOLS_MESSAGE_VARIABLE_H
25 
30 
31 namespace variant_topic_tools {
35  public MessageMember {
36  friend class MessageDataType;
37  friend class MessageMember;
38  friend class MessageVariant;
39  public:
43 
46  MessageVariable(const MessageVariable& src);
47 
50  MessageVariable(const MessageMember& src);
51 
55 
56  protected:
59  class Impl :
60  public MessageMember::Impl {
61  public:
64  Impl(const std::string& name, const DataType& type);
65 
68  virtual ~Impl();
69 
72  const DataType& getType() const;
73 
76  void write(std::ostream& stream) const;
77 
81  };
82 
86  template <typename T> class ImplT :
87  public Impl {
88  public:
89  BOOST_STATIC_ASSERT(type_traits::IsMessage<T>::value);
90 
94 
97  ImplT(const std::string& name, const DataType& type);
98 
101  virtual ~ImplT();
102 
106  virtual Variant createVariant(const Pointer<ValueType>& message)
107  const = 0;
108  };
109 
113  template <typename T, typename M> class ImplM :
114  public ImplT<T> {
115  public:
118  typedef typename ImplT<T>::ValueType ValueType;
119 
122  ImplM(const std::string& name, const DataType& type, size_t offset);
123 
126  virtual ~ImplM();
127 
131  Variant createVariant(const Pointer<ValueType>& message) const;
132 
135  size_t offset;
136  };
137 
140  MessageVariable(const std::string& name, const DataType& type);
141 
144  template <typename T, typename M> static MessageVariable create(const
145  std::string& name, size_t offset);
146  };
147 };
148 
149 #include <variant_topic_tools/MessageVariable.tpp>
150 
151 #endif
Header file providing the DataType class interface.
DataType type
The data type of this message variable.
MessageVariable()
Default constructor.
type_traits::MessageType< T >::ValueType ValueType
Definition of the value type.
Header file providing the MessageMember class interface.
Message variable implementation.
std::string name
The name of this message member.
Message variable implementation (version templated on the message type and the member type) ...
const DataType & getType() const
Retrieve the type of this message member (implementation)
Impl(const std::string &name, const DataType &type)
Constructor.
static MessageVariable create(const std::string &name, size_t offset)
Create a message variable.
Header file providing the message type traits.
ImplT< T >::ValueType ValueType
Definition of the value type.
void write(std::ostream &stream) const
Write the message member to a stream (implementation)
Header file providing the Pointer class interface.
size_t offset
The memory offset of this message variable.
Message member implementation.
Definition: MessageMember.h:79
Message variable implementation (version templated on the message type)


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49