AddAddress.hpp
1 #pragma once
2 #include <Device/Address/AddressSettings.hpp>
3 #include <Device/Node/DeviceNode.hpp>
4 
5 #include <Explorer/Commands/DeviceExplorerCommandFactory.hpp>
6 
7 #include <score/command/AggregateCommand.hpp>
8 #include <score/command/Command.hpp>
9 #include <score/model/path/Path.hpp>
10 #include <score/model/tree/TreePath.hpp>
11 
12 #include <score_plugin_deviceexplorer_export.h>
13 
14 namespace Explorer
15 {
16 class DeviceDocumentPlugin;
17 namespace Command
18 {
19 
20 class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT AddAddress final : public score::Command
21 {
22  SCORE_COMMAND_DECL(DeviceExplorerCommandFactoryName(), AddAddress, "Add an address")
23 public:
24  AddAddress(
25  const DeviceDocumentPlugin& devplug, const Device::NodePath& nodePath,
26  InsertMode insert, const Device::AddressSettings& addressSettings);
27 
28  void undo(const score::DocumentContext& ctx) const override;
29  void redo(const score::DocumentContext& ctx) const override;
30 
31  int createdNodeIndex() const;
32 
33 protected:
34  void serializeImpl(DataStreamInput&) const override;
35  void deserializeImpl(DataStreamOutput&) override;
36 
37 private:
38  Device::NodePath m_parentNodePath;
39  Device::AddressSettings m_addressSettings;
40  int m_createdLevels{};
41 };
42 
43 class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT AddWholeAddress final : public score::Command
44 {
45  SCORE_COMMAND_DECL(
46  DeviceExplorerCommandFactoryName(), AddWholeAddress, "Add an address")
47 public:
49  const DeviceDocumentPlugin& devplug, const Device::FullAddressSettings& addr);
50 
51  void undo(const score::DocumentContext& ctx) const override;
52  void redo(const score::DocumentContext& ctx) const override;
53 
54 protected:
55  void serializeImpl(DataStreamInput&) const override;
56  void deserializeImpl(DataStreamOutput&) override;
57 
58 private:
59  Device::FullAddressSettings m_addressSettings;
60  int m_existsUpTo{};
61 };
62 
63 class SCORE_PLUGIN_DEVICEEXPLORER_EXPORT AddAddresses final
65 {
66  SCORE_COMMAND_DECL(DeviceExplorerCommandFactoryName(), AddAddresses, "Add addresses")
67 };
68 }
69 }
Definition: AddAddress.hpp:21
Definition: AddAddress.hpp:65
Definition: AddAddress.hpp:44
Path in a tree of QAbstractItemModel objects.
Definition: TreePath.hpp:34
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
The Command class.
Definition: Command.hpp:34
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: AddressSettings.hpp:49
Definition: AddressSettings.hpp:62
Definition: DocumentContext.hpp:18