FEDEM Solver  R8.0
Source code of the dynamics solver
FFrItemGroup.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 FFR_ITEM_GROUP_H
9 #define FFR_ITEM_GROUP_H
10 
12 #include "FFrLib/FFrEnums.H"
13 #include <cstdio>
14 
15 class FFrCreatorData;
16 
17 
19 {
20 public:
21  FFrItemGroup(bool inlined = false);
22  FFrItemGroup(const FFrItemGroup& obj);
23  virtual ~FFrItemGroup();
24 
25  FFrItemGroup& operator=(const FFrItemGroup&) = delete;
26 
27  static FFrStatus create(FILE* varStream, FFrCreatorData& cd, bool dataBlocks);
28 
29  int fillObject(const std::vector<std::string>& tokens, FFrCreatorData& cd);
30 
31  virtual int traverse(FFrResultContainer* resultContainer,
32  FFrEntryBase* owner,
33  FFrEntryBase*& objToBeModified,
34  int binPos);
35 
36  virtual bool compare(const FFrEntryBase* obj) const;
37  virtual bool equal(const FFrEntryBase* obj) const;
38  virtual bool less(const FFrEntryBase* obj) const;
39 
40  virtual int getUserID() const { return myId; }
41  virtual bool hasUserID() const { return myId > 0; }
42 
43  virtual const std::string& getType() const;
44  virtual const std::string& getDescription() const { return this->getType(); }
45  virtual bool hasDescription() const { return true; }
46 
47  virtual bool isIG() const { return true; }
48  virtual void setGlobal();
49 
50 private:
51  std::set<std::string>::const_iterator myNameIt;
52 
53  union {
54  int myId; // -1 means a named item group and myNameIt points to its name
55  FFrItemGroup* next; // used in memory management
56  };
57  bool isInlined;
58 
59 #if FFR_DEBUG > 2
60  static long int count;
61 #endif
62 
63 public:
64  struct Less
65  {
66  bool operator()(const FFrItemGroup* first, const FFrItemGroup* sec) const;
67  };
68 
69 #ifdef FFR_NEWALLOC
70  // overloading the new & delete opers
71  static void* operator new(size_t size);
72  static void operator delete(void* deadObject, size_t size);
73 
74  static void releaseMemBlocks();
75 
76 private:
77  static size_t newed;
78  static FFrItemGroup* headOfFreeList;
79  static std::vector<FFrItemGroup*> memBlocks;
80 #endif
81 };
82 
83 typedef std::set<FFrItemGroup*,FFrItemGroup::Less> ItemGroupSet;
84 typedef ItemGroupSet::const_iterator ItemGroupSetCIt;
85 typedef ItemGroupSet::iterator ItemGroupSetIt;
86 
87 #endif
FFrStatus
Definition: FFrEnums.H:12
ItemGroupSet::const_iterator ItemGroupSetCIt
Definition: FFrItemGroup.H:84
std::set< FFrItemGroup *, FFrItemGroup::Less > ItemGroupSet
Definition: FFrItemGroup.H:83
ItemGroupSet::iterator ItemGroupSetIt
Definition: FFrItemGroup.H:85
Definition: FFrEntryBase.H:28
Definition: FFrFieldEntryBase.H:17
Definition: FFrItemGroup.H:19
std::set< std::string >::const_iterator myNameIt
Definition: FFrItemGroup.H:51
virtual bool hasDescription() const
Definition: FFrItemGroup.H:45
FFrItemGroup * next
Definition: FFrItemGroup.H:55
virtual int getUserID() const
Returns userID for objects that have a userID (OG and some IGs).
Definition: FFrItemGroup.H:40
virtual bool hasUserID() const
Definition: FFrItemGroup.H:41
int myId
Definition: FFrItemGroup.H:54
int fillObject(const std::vector< std::string > &tokens, FFrCreatorData &cd)
Definition: FFrItemGroup.C:138
FFrItemGroup & operator=(const FFrItemGroup &)=delete
virtual void setGlobal()
Defines this as a global-scope entry (as opposed to container-scope).
Definition: FFrItemGroup.C:230
virtual int traverse(FFrResultContainer *resultContainer, FFrEntryBase *owner, FFrEntryBase *&objToBeModified, int binPos)
Traverses to build owner hierarchy and calculate binary sizes.
Definition: FFrItemGroup.C:205
virtual const std::string & getDescription() const
Definition: FFrItemGroup.H:44
virtual bool less(const FFrEntryBase *obj) const
Definition: FFrItemGroup.C:256
virtual bool compare(const FFrEntryBase *obj) const
Definition: FFrItemGroup.C:238
bool isInlined
Definition: FFrItemGroup.H:57
virtual ~FFrItemGroup()
Definition: FFrItemGroup.C:47
FFrItemGroup(bool inlined=false)
Definition: FFrItemGroup.C:17
static FFrStatus create(FILE *varStream, FFrCreatorData &cd, bool dataBlocks)
Definition: FFrItemGroup.C:66
virtual const std::string & getType() const
Definition: FFrItemGroup.C:56
virtual bool equal(const FFrEntryBase *obj) const
Definition: FFrItemGroup.C:250
virtual bool isIG() const
Definition: FFrItemGroup.H:47
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71
Incapsulation of temporary data used during results file parsing.
Definition: FFrResultContainer.H:36
Definition: FFrItemGroup.H:65
bool operator()(const FFrItemGroup *first, const FFrItemGroup *sec) const
Definition: FFrItemGroup.C:179