DbcLib 1.0
CAN DBC C++ library.
Loading...
Searching...
No Matches
envvar.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Ingemar Hedvall
3 * SPDX-License-Identifier: MIT
4 */
5
9#pragma once
10
11#include <cstdint>
12#include <string>
13#include <vector>
14#include <map>
15
16namespace dbc {
18enum class EnvType : int {
19 IntegerType = 0,
20 FloatType = 1,
21 StringType = 2,
22 DataType = 3
23};
24
26enum class AccessType : int {
27 Unrestricted = 0,
28 ReadOnly = 1,
29 WriteOnly = 2,
30 ReadWrite = 3
31};
32
34class EnvVar {
35 public:
37 void Name(const std::string& name) { name_ = name; }
39 [[nodiscard]] const std::string& Name() const { return name_; }
40
42 void Comment(const std::string& comment) { comment_ = comment;}
44 [[nodiscard]] const std::string& Comment() const { return comment_; }
45
47 void Type(EnvType type) { type_ = type; }
49 [[nodiscard]] EnvType Type() const { return type_; }
51 [[nodiscard]] std::string TypeAsString() const;
52
53 void Min(double min) { min_ = min; }
54 [[nodiscard]] double Min() const { return min_;}
55
56 void Max(double max) {max_ = max;}
57 [[nodiscard]] double Max() const { return max_;}
58
59 void Unit(const std::string& unit) { unit_ = unit; }
60 [[nodiscard]] const std::string& Unit() const { return unit_; }
61
63 void InitValue(double value) {init_value_ = value;}
65 [[nodiscard]] double InitValue() const { return init_value_; }
66
67 void Ident(uint64_t ident) {ident_ = ident;}
68 [[nodiscard]] uint64_t Ident() const { return ident_;}
69
70 void Access(AccessType type) { access_type_ = type; }
71 [[nodiscard]] AccessType Access() const { return access_type_; }
72
74 void NodeList(const std::vector<std::string>& node_list) {
75 node_list_ = node_list;
76 }
78 [[nodiscard]] const std::vector<std::string>& NodeList() const {
79 return node_list_;
80 }
81
83 void EnumList(const std::map<int64_t, std::string>& enum_list);
85 [[nodiscard]] const std::map<int64_t, std::string>& EnumList() const;
86
87 private:
88 std::string name_;
89 std::string comment_;
91 double min_ = 0.0;
92 double max_ = 0.0;
93 std::string unit_;
94 double init_value_ = 0.0;
95 uint64_t ident_ = 0;
97 std::vector<std::string> node_list_;
98 std::map<int64_t, std::string> enum_list_;
99};
100
101} // namespace dbc
Wrapper around an environment DBC variable.
Definition: envvar.h:34
EnvType Type() const
Returns the data type.
Definition: envvar.h:49
void EnumList(const std::map< int64_t, std::string > &enum_list)
Sets the enumerate list.
const std::string & Comment() const
Return the descriptive text.
Definition: envvar.h:44
void Max(double max)
Sets the max range.
Definition: envvar.h:56
const std::vector< std::string > & NodeList() const
Returns the node list.
Definition: envvar.h:78
void Name(const std::string &name)
Sets the name.
Definition: envvar.h:37
void NodeList(const std::vector< std::string > &node_list)
Sets the node list.
Definition: envvar.h:74
void Access(AccessType type)
Sets the access.
Definition: envvar.h:70
void Comment(const std::string &comment)
Sets the descriptive text.
Definition: envvar.h:42
const std::string & Name() const
Retuns the name.
Definition: envvar.h:39
void Unit(const std::string &unit)
Sets the unit.
Definition: envvar.h:59
uint64_t Ident() const
Identity.
Definition: envvar.h:68
double Max() const
Max range.
Definition: envvar.h:57
const std::map< int64_t, std::string > & EnumList() const
Returns the node list.
std::string TypeAsString() const
Returns the data type as string.
void InitValue(double value)
Sets the initial value.
Definition: envvar.h:63
void Min(double min)
Sets the min range.
Definition: envvar.h:53
void Ident(uint64_t ident)
Sets the identity.
Definition: envvar.h:67
AccessType Access() const
Access.
Definition: envvar.h:71
double InitValue() const
Returns the initial value.
Definition: envvar.h:65
const std::string & Unit() const
Unit.
Definition: envvar.h:60
double Min() const
Min range.
Definition: envvar.h:54
void Type(EnvType type)
Sets the data type.
Definition: envvar.h:47
Main namespace for the DBC library.
Definition: attribute.h:13
EnvType
The variable data type.
Definition: envvar.h:18
@ FloatType
Floating point variable.
@ IntegerType
Integer variable.
@ DataType
Data type variable.
@ StringType
Text variable.
AccessType
Type of access.
Definition: envvar.h:26
@ ReadOnly
Read-only access.
@ WriteOnly
Write-only access.
@ ReadWrite
Read and write access.
@ Unrestricted
Unrestricted access.