DbcMessage.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015-2020, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DBC_MESSAGE_HPP
36 #define _DBC_MESSAGE_HPP
37 
38 #include <stdint.h>
39 #include <string>
40 #include <vector>
41 #include <iosfwd>
42 #include <set>
43 
44 #include "DbcSignal.hpp"
45 
50 class Message {
51 
52  typedef std::vector<Signal> signals_t;
53  // Name of the Message
54  std::string name;
55  // The CAN-ID assigned to this specific Message
56  uint32_t id;
57  // The length of this message in Bytes. Allowed values are between 0 and 8
58  std::size_t dlc;
59  // String containing the name of the Sender of this Message if one exists in the DB
60  std::string from;
61  // List containing all Signals which are present in this Message
62  signals_t signals;
63 
64 public:
65  typedef signals_t::const_iterator const_iterator;
66  // Overload of operator>> to enable parsing of Messages from streams of DBC-Files
67  friend std::istream& operator>>(std::istream& in, Message& msg);
68 
69  // Getter functions for all the possible Data one can request from a Message
70  const std::string& getName() const { return name; }
71  uint32_t getId() const { return id; }
72  std::size_t getDlc() const { return dlc; }
73  const std::string& getFrom() const { return from; }
74  std::set<std::string> getTo() const;
75 
76  /*
77  * Functionality to access the Signals contained in this Message
78  * either via the iterators provided by begin() and end() or by
79  * random access operator[]
80  */
81  const_iterator begin() const { return signals.begin(); }
82  const_iterator end() const { return signals.end(); }
83  signals_t::const_reference operator[](std::size_t elem) {
84  return signals[elem];
85  }
86 
87 };
88 
89 #endif /* _DBC_MESSAGE_HPP */
90 
std::set< std::string > getTo() const
Definition: DbcMessage.cpp:79
const_iterator begin() const
Definition: DbcMessage.hpp:81
std::vector< Signal > signals_t
Definition: DbcMessage.hpp:52
friend std::istream & operator>>(std::istream &in, Message &msg)
Definition: DbcMessage.cpp:41
const_iterator end() const
Definition: DbcMessage.hpp:82
std::string name
Definition: DbcMessage.hpp:54
signals_t::const_iterator const_iterator
Definition: DbcMessage.hpp:65
uint32_t id
Definition: DbcMessage.hpp:56
signals_t signals
Definition: DbcMessage.hpp:62
uint32_t getId() const
Definition: DbcMessage.hpp:71
signals_t::const_reference operator[](std::size_t elem)
Definition: DbcMessage.hpp:83
std::size_t dlc
Definition: DbcMessage.hpp:58
std::string from
Definition: DbcMessage.hpp:60
std::size_t getDlc() const
Definition: DbcMessage.hpp:72
const std::string & getName() const
Definition: DbcMessage.hpp:70
const std::string & getFrom() const
Definition: DbcMessage.hpp:73


dataspeed_can_tools
Author(s): Micho Radovnikovich
autogenerated on Thu Jul 9 2020 03:41:59