CANdevStudio
Development tool for CAN bus simulation
Loading...
Searching...
No Matches
modelvisitor.h
Go to the documentation of this file.
1
2#ifndef MODELVISITOR_H
3#define MODELVISITOR_H
4
5#include <utility> // move, forward
6
7#include <nodes/NodeDataModel>
8
9#include "visitor.h" // Visitor
10#include "visitablewith.h" // VisitableWith
11
12
13class CanRawViewModel;
15class CanDeviceModel;
16
34 : Visitor<
35 CanNodeDataModelVisitor // tag, not visitable type!
36 , CanRawViewModel
37 , CanRawSenderModel
38 , CanDeviceModel
39// , Other
40 >
41{
42 using Visitor::Visitor;
43};
44
45
47inline void apply_model_visitor(QtNodes::NodeDataModel& m, CanNodeDataModelVisitor v)
48{
49 // NOTE: Cannot use static_cast since NodeDataModel and VisitableWith
50 // are not in direct inheritance relation, i.e. only type derived
51 // from NodeDataModel derives from VisitableWith.
52
53 dynamic_cast<VisitableWith<CanNodeDataModelVisitor>&>(m).visit(v); // throws!
54}
55
57template<class... Actions>
58inline void apply_model_visitor(QtNodes::NodeDataModel& m, Actions&&... actions)
59{
60 CanNodeDataModelVisitor v{std::forward<Actions>(actions)...};
61
62 apply_model_visitor(m, std::move(v));
63}
64
65#endif
66
The class provides node graphical representation of CanDevice.
Definition candevicemodel.h:21
The class provides node graphical representation of CanRawSender.
Definition canrawsendermodel.h:17
The class provides node graphical representation of CanRawView.
Definition canrawviewmodel.h:17
Definition visitor.h:41
Visitor(Fs &&... fs)
Definition visitor.h:147
void apply_model_visitor(QtNodes::NodeDataModel &m, CanNodeDataModelVisitor v)
Definition modelvisitor.h:47
Definition modelvisitor.h:41
Definition visitablewith.h:49