Emergency 20 Dokumentation  4.2.0
SelectionManager-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Includes ]
6 //[-------------------------------------------------------]
8 
9 
10 //[-------------------------------------------------------]
11 //[ Namespace ]
12 //[-------------------------------------------------------]
13 namespace em5
14 {
15 
16 
17  //[-------------------------------------------------------]
18  //[ Public methods ]
19  //[-------------------------------------------------------]
21  {
22  // Nothing here
23  }
24 
26  {
27  // Nothing here
28  }
29 
31  {
32  const IdSet& set = getSelectedIdSet();
33  uint32 idSetSize = static_cast<uint32>(set.size());
34  uint64 currentId = getCurrentId();
35  serializer.serialize(idSetSize);
36  serializer.serialize(currentId);
37 
38  if (serializer.isReading())
39  {
40  // Reading
42  for (uint32 i = 0; i < idSetSize; ++i)
43  {
44  // Serialize
45  uint64 id = qsf::getUninitialized<uint64>();
46  serializer.serialize(id);
47  addIdToSelection(id);
48  }
49  setCurrentId(currentId);
50  }
51  else
52  {
53  for (uint64 id : set)
54  {
55  serializer.serialize(id);
56  }
57  }
58  }
59 
60 
61 //[-------------------------------------------------------]
62 //[ Namespace ]
63 //[-------------------------------------------------------]
64 } // em5
uint64 getCurrentId() const
Return the current ID (the focus of attention)
Definition: ActionPriority.h:13
const IdSet & getSelectedIdSet() const
Return whole selection as set of IDs.
SelectionManager()
Default constructor.
Definition: SelectionManager-inl.h:20
unsigned int uint32
Definition: PlatformTypes.h:181
void serialize(T &value, const char *name=nullptr)
Serialize or deserialize a value with optional name (for usage as additional security token) ...
Definition: BinarySerializer-inl.h:52
uint64_t uint64
Definition: PlatformTypes.h:184
void setCurrentId(uint64 id)
Set the current ID (the focus of attention)
void serialize(qsf::BinarySerializer &serializer)
Serialization of the selection.
Definition: SelectionManager-inl.h:30
boost::container::flat_set< uint64 > IdSet
Definition: SelectionManagerTemplate.h:52
void clearSelection()
Clear the current selection.
virtual ~SelectionManager()
Destructor.
Definition: SelectionManager-inl.h:25
void addIdToSelection(uint64 id)
Add an ID to the current selection.
bool isReading() const
Return whether the serializer is currently reading/deserializing.
Definition: BinarySerializer-inl.h:41
Binary serializer class.
Definition: BinarySerializer.h:35