FEDEM Model Database  R8.0
Source code of the FEDEM model database
FFlGroup.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFL_GROUP_H
9 #define FFL_GROUP_H
10 
12 #include "FFlLib/FFlReference.H"
13 #include "FFlLib/FFlTypeInfoSpec.H"
14 
15 class FFaCheckSum;
16 
17 #ifdef FF_NAMESPACE
18 namespace FF_NAMESPACE {
19 #endif
20 
21 class FFlElementBase;
22 
24 using GroupElemVec = std::vector<GroupElemRef>;
25 
26 
27 class FFlGroup : public FFlNamedPartBase
28 {
29 public:
30  FFlGroup(int id, const std::string& groupName = "New group");
31  virtual ~FFlGroup() {}
32 
33  static void init();
34 
35  bool resolveElemRefs(std::vector<FFlElementBase*>& possibleReferences,
36  bool suppressErrmsg = false);
37 
38  void addElement(FFlElementBase* elementRef, bool sortOnInsert = false);
39  void addElement(int elementID, bool sortOnInsert = false);
40  void swapElement(int oldElmID, const std::vector<int>& newElmID);
41  bool removeElement(int elementID) { return this->remove(elementID); }
42  bool removeElement(FFlElementBase* element) { return this->remove(element); }
43 
44  bool hasElement(int elementID) const;
45 
46  void sortElements(bool removeDuplicates = false);
47  size_t size() const { return myElements.size(); }
48 
49  GroupElemVec::const_iterator begin() const { return myElements.begin(); }
50  GroupElemVec::const_iterator end() const { return myElements.end(); }
51 
52  FFlGroup* clone() const { return new FFlGroup(*this); }
53 
54  void calculateChecksum(FFaCheckSum* cs, int csMask) const;
55 
57 
58 protected:
59  bool remove(const GroupElemRef& elmRef);
60 
61 private:
63  bool iAmSorted;
64 };
65 
66 #ifdef FF_NAMESPACE
67 } // namespace
68 #endif
69 #endif
std::vector< GroupElemRef > GroupElemVec
Definition: FFlGroup.H:24
Class for holding and calculation of checksum value of objects.
Definition: FFaCheckSum.H:30
Definition: FFlElementBase.H:43
Class for grouping of elements.
Definition: FFlGroup.H:28
size_t size() const
Definition: FFlGroup.H:47
FFlGroup * clone() const
Definition: FFlGroup.H:52
bool removeElement(int elementID)
Definition: FFlGroup.H:41
GroupElemVec myElements
Definition: FFlGroup.H:62
GroupElemVec::const_iterator end() const
Definition: FFlGroup.H:50
virtual ~FFlGroup()
Definition: FFlGroup.H:31
GroupElemVec::const_iterator begin() const
Definition: FFlGroup.H:49
bool iAmSorted
Definition: FFlGroup.H:63
bool removeElement(FFlElementBase *element)
Definition: FFlGroup.H:42
FFL_TYPE_INFO(FFlGroup)
Definition: FFlNamedPartBase.H:21
void init()
Definition: FmDB.C:518