FEDEM Solver  R8.0
Source code of the dynamics solver
FFrEntryBase.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 
13 #ifndef FFR_ENTRY_BASE_H
14 #define FFR_ENTRY_BASE_H
15 
16 #ifdef FFR_LISTVIEW
18 #endif
19 #include <iostream>
20 #include <string>
21 #include <vector>
22 #include <set>
23 
24 class FFrEntryBase;
25 class FFrResultContainer;
27 
28 using FFrEntries = std::vector<FFrEntryBase*>;
29 
30 
37 #ifdef FFR_LISTVIEW
38 class FFrEntryBase : public FFaListViewItem
39 #else
41 #endif
42 {
43 protected:
45  FFrEntryBase() : myOwner(NULL), myGlobal(false)
46  {
47 #if FFR_DEBUG > 2
48  myCount = 0;
49 #endif
50  }
53  {
54  myOwner = obj.myOwner;
55  myGlobal = obj.myGlobal;
56 #if FFR_DEBUG > 2
57  myCount = 0;
58 #endif
59  }
61  FFrEntryBase& operator=(const FFrEntryBase&) = delete;
62 
63 public:
65  virtual ~FFrEntryBase() {}
66 
69 
71  virtual const std::string& getDescription() const = 0;
73  virtual bool hasDescription() const { return false; }
74 
79  virtual const std::string& getType() const = 0;
80 
81 #ifdef FFR_LISTVIEW
83  virtual const char* getItemName() const { return this->getType().c_str(); }
85  virtual std::string getItemDescr() const { return ""; }
87  virtual int getItemID() const { return 0; }
89  virtual int getItemBaseID() const { return this->getBaseID(); }
90 #endif
91 
94  virtual int getBaseID() const { return 0; }
96  virtual bool hasBaseID() const { return false; }
97 
101  virtual int getUserID() const { return 0; }
103  virtual bool hasUserID() const { return false; }
104 
107  virtual const FFrEntries* getDataFields() const { return NULL; }
109  virtual bool hasDataFields() const { return false; }
110 
112  template<class T>
113  int readPositionedTimestepData(const T* values, int nvals) const
114  { return this->readPosData(values,nvals); }
115 
117  virtual void printPosition(std::ostream& os) const = 0;
118 #if FFR_DEBUG > 2
120  void printID(std::ostream& os, bool EOL = true) const;
121 #endif
122 
124  FFrEntryBase* getOwner() const { return myOwner; }
126 #if FFR_DEBUG > 2
127  void setOwner(FFrEntryBase* owner);
128 #else
129  void setOwner(FFrEntryBase* owner) { myOwner = owner; }
130 #endif
133  virtual void setGlobal() { myGlobal = true; }
135  bool isGlobal() const { return myGlobal; }
136 
138  virtual bool isOG() const { return false; }
140  virtual bool isSOG() const { return false; }
142  virtual bool isIG() const { return false; }
144  virtual bool isVarRef() const { return false; }
145 
147  virtual bool isEmpty() const = 0;
148 
150  virtual bool isVariableFloat() const = 0;
151 
152  // "Private" public methods
153 
155  virtual void removeContainers(const std::set<FFrResultContainer*>& cont) = 0;
156 
159  int binPos) { return binPos; }
160 
162  virtual bool merge(FFrEntryBase* objToMergeFrom) = 0;
164  virtual bool comp(const FFrEntryBase*) const { return false; }
166  virtual bool equal(const FFrEntryBase* obj) const = 0;
168  virtual bool less(const FFrEntryBase* obj) const = 0;
169 
171  virtual int readPosData(const double* vals, int nvals, int pos = 0) const = 0;
173  virtual int readPosData(const float* vals, int nvals, int pos = 0) const = 0;
175  virtual int readPosData(const int* vals, int nvals, int pos = 0) const = 0;
176 
178  template<class T> bool readVar(T& value);
179 
180 private:
182  bool myGlobal;
183 
184 #if FFR_DEBUG > 2
185 protected:
186  long int myCount;
187 #endif
188 };
189 
190 #endif
Base class for list view items.
std::vector< FFrEntryBase * > FFrEntries
Convenience type alias.
Definition: FFrEntryBase.H:28
Base class for list view items.
Definition: FFaListViewItem.H:31
Class representing a result variable description.
Definition: FFaResultDescription.H:31
Base class for result file entries.
Definition: FFrEntryBase.H:42
virtual bool merge(FFrEntryBase *objToMergeFrom)=0
Merges another entry into *this.
virtual bool hasUserID() const
Returns whether this entry has a user ID or not.
Definition: FFrEntryBase.H:103
virtual void removeContainers(const std::set< FFrResultContainer * > &cont)=0
Removes data associated with given containers for this entry.
bool readVar(T &value)
Reads a variable from the results container for current time step.
Definition: FFrEntryBase.C:84
virtual void setGlobal()
Defines this as a global scope entry.
Definition: FFrEntryBase.H:133
virtual int traverse(FFrResultContainer *, FFrEntryBase *, FFrEntryBase *&, int binPos)
Traverses to build owner hierarchy and calculate binary sizes.
Definition: FFrEntryBase.H:158
FFrEntryBase * getOwner() const
Returns the owner of this entry in the hierarchy.
Definition: FFrEntryBase.H:124
virtual bool hasBaseID() const
Returns whether this entry has a base ID or not.
Definition: FFrEntryBase.H:96
FFrEntryBase()
Default constructor.
Definition: FFrEntryBase.H:45
FFaResultDescription getEntryDescription() const
Returns the full path of this result entry.
Definition: FFrEntryBase.C:56
virtual bool isSOG() const
Returns whether this entry is a Super Object Group or not.
Definition: FFrEntryBase.H:140
virtual void printPosition(std::ostream &os) const =0
Prints out the positioning data of this entry.
virtual const FFrEntries * getDataFields() const
Returns a pointer to the data fields of this entry.
Definition: FFrEntryBase.H:107
virtual bool equal(const FFrEntryBase *obj) const =0
Returns true if *this and *obj are considered equal.
virtual int readPosData(const double *vals, int nvals, int pos=0) const =0
Reads double data from the hierarhcy under this entry.
virtual int getUserID() const
Returns the user ID for this entry.
Definition: FFrEntryBase.H:101
virtual bool hasDataFields() const
Returns whether this entry has data fields or not.
Definition: FFrEntryBase.H:109
virtual int getBaseID() const
Returns the base ID of the object if this entry is an Object Group.
Definition: FFrEntryBase.H:94
virtual bool isVariableFloat() const =0
Returns true if the first variable referred is a float.
virtual bool isEmpty() const =0
Returns true if this entry and all below it are empty.
virtual bool less(const FFrEntryBase *obj) const =0
Returns true if *this is ordered before *obj.
virtual const std::string & getDescription() const =0
Returns the description of this entry.
virtual ~FFrEntryBase()
Empty destructor.
Definition: FFrEntryBase.H:65
FFrEntryBase(const FFrEntryBase &obj)
Copy constructor.
Definition: FFrEntryBase.H:52
FFrEntryBase & operator=(const FFrEntryBase &)=delete
Disable default assignment operator.
virtual bool comp(const FFrEntryBase *) const
Returns true if *this equals another specified entry.
Definition: FFrEntryBase.H:164
virtual const std::string & getType() const =0
Returns the referred object type.
virtual int readPosData(const int *vals, int nvals, int pos=0) const =0
Reads integer data from the hierarhcy under this entry.
bool isGlobal() const
Check if this entry is in global scope or not.
Definition: FFrEntryBase.H:135
virtual bool isVarRef() const
Returns whether this entry is a Variable Reference or not.
Definition: FFrEntryBase.H:144
void setOwner(FFrEntryBase *owner)
Defines the owner of this entry in the hierarchy.
Definition: FFrEntryBase.H:129
virtual bool hasDescription() const
Returns whether the entry has a description or not.
Definition: FFrEntryBase.H:73
virtual bool isOG() const
Returns whether this entry is an Object Group or not.
Definition: FFrEntryBase.H:138
int readPositionedTimestepData(const T *values, int nvals) const
Reads variable reference data from the hierarhcy under this entry.
Definition: FFrEntryBase.H:113
bool myGlobal
Global (extractor-level) or local (container level)
Definition: FFrEntryBase.H:182
virtual bool isIG() const
Returns whether this entry is an Item Group or not.
Definition: FFrEntryBase.H:142
FFrEntryBase * myOwner
Parent of this entry in the RDB hierchy.
Definition: FFrEntryBase.H:181
virtual int readPosData(const float *vals, int nvals, int pos=0) const =0
Reads float data from the hierarhcy under this entry.
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71