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 
8 #ifndef FFR_ENTRY_BASE_H
9 #define FFR_ENTRY_BASE_H
10 
11 #ifdef FFR_LISTVIEW
13 #endif
14 #include <iostream>
15 #include <string>
16 #include <vector>
17 #include <set>
18 
19 class FFrResultContainer;
21 
22 
23 #ifdef FFR_LISTVIEW
24 class FFrEntryBase : public FFaListViewItem
25 #else
27 #endif
28 {
29 public:
31  FFrEntryBase() : myOwner(NULL), myGlobal(false)
32  {
33 #if FFR_DEBUG > 2
34  myCount = 0;
35 #endif
36  }
39  {
40  myOwner = obj.myOwner;
41  myGlobal = obj.myGlobal;
42 #if FFR_DEBUG > 2
43  myCount = 0;
44 #endif
45  }
47  FFrEntryBase& operator=(const FFrEntryBase&) = delete;
49  virtual ~FFrEntryBase() {}
50 
53 
56  virtual const std::string& getDescription() const = 0;
57  virtual bool hasDescription() const { return false; }
58 
62  virtual const std::string& getType() const = 0;
63 
64 #ifdef FFR_LISTVIEW
65  // From FFaListViewItem
66  virtual const char* getItemName() const { return this->getType().c_str(); }
67  // The next two methods always return 0 to avoid that result items are sorted
68  virtual std::string getItemDescr() const { return ""; }
69  virtual int getItemID() const { return 0; }
70  virtual int getItemBaseID() const { return this->getBaseID(); }
71 #endif
72 
74  virtual int getBaseID() const { return 0; }
75  virtual bool hasBaseID() const { return false; }
76 
78  virtual int getUserID() const { return 0; }
79  virtual bool hasUserID() const { return false; }
80 
82  virtual const std::vector<FFrEntryBase*>* getDataFields() const { return 0; }
83  virtual bool hasDataFields() const { return false; }
84 
86  template<class T>
87  int readPositionedTimestepData(const T* values, int nvals) const
88  { return this->recursiveReadPosData(values, nvals, 0); }
89 
91  virtual void printPosition(std::ostream& os) const = 0;
92 #if FFR_DEBUG > 2
93  void printID(std::ostream& os, bool EOL = true) const;
94 #endif
95 
97  FFrEntryBase* getOwner() const { return myOwner; }
99 #if FFR_DEBUG > 2
100  void setOwner(FFrEntryBase* owner);
101 #else
102  void setOwner(FFrEntryBase* owner) { myOwner = owner; }
103 #endif
105  virtual void setGlobal() { myGlobal = true; }
107  bool isGlobal() const { return myGlobal; }
108 
109  // Simple type checking
110  virtual bool isOG() const { return false; }
111  virtual bool isSOG() const { return false; }
112  virtual bool isIG() const { return false; }
113  virtual bool isVarRef() const { return false; }
114 
116  virtual bool isEmpty() const = 0;
117 
119  virtual bool isVariableFloat() const = 0;
120 
121  // "Private" public methods
122 
123  virtual void removeContainers(const std::set<FFrResultContainer*>& cont) = 0;
124 
127  int binPos) { return binPos; }
128 
129  virtual bool merge(FFrEntryBase* objToMergeFrom) = 0;
130  virtual bool compare(const FFrEntryBase*) const { return false; }
131  virtual bool equal(const FFrEntryBase* obj) const = 0;
132  virtual bool less(const FFrEntryBase* obj) const = 0;
133 
134  virtual int recursiveReadPosData(const double* vals, int nvals, int arrayPos) const = 0;
135  virtual int recursiveReadPosData(const float* vals, int nvals, int arrayPos) const = 0;
136  virtual int recursiveReadPosData(const int* vals, int nvals, int arrayPos) const = 0;
137 
138 private:
140  bool myGlobal;
141 
142 #if FFR_DEBUG > 2
143 protected:
144  long int myCount;
145 #endif
146 };
147 
148 #endif
Base class for list view items.
Definition: FFaListViewItem.H:26
Class representing a result variable description.
Definition: FFaResultDescription.H:31
Definition: FFrEntryBase.H:28
virtual bool merge(FFrEntryBase *objToMergeFrom)=0
virtual bool hasUserID() const
Definition: FFrEntryBase.H:79
virtual void removeContainers(const std::set< FFrResultContainer * > &cont)=0
virtual void setGlobal()
Defines this as a global-scope entry (as opposed to container-scope).
Definition: FFrEntryBase.H:105
virtual int traverse(FFrResultContainer *, FFrEntryBase *, FFrEntryBase *&, int binPos)
Traverses to build owner hierarchy and calculate binary sizes.
Definition: FFrEntryBase.H:126
FFrEntryBase * getOwner() const
Returns the owner of this entry in the hierarchy.
Definition: FFrEntryBase.H:97
virtual bool hasBaseID() const
Definition: FFrEntryBase.H:75
FFrEntryBase()
Default constructor.
Definition: FFrEntryBase.H:31
FFaResultDescription getEntryDescription() const
Returns the full path of this result entry.
Definition: FFrEntryBase.C:49
virtual bool isSOG() const
Definition: FFrEntryBase.H:111
virtual void printPosition(std::ostream &os) const =0
Prints out the positioning data of this entry.
virtual bool equal(const FFrEntryBase *obj) const =0
virtual int getUserID() const
Returns userID for objects that have a userID (OG and some IGs).
Definition: FFrEntryBase.H:78
virtual bool hasDataFields() const
Definition: FFrEntryBase.H:83
virtual int getBaseID() const
Returns baseID for objects that have a baseID. Returns 0 for other types.
Definition: FFrEntryBase.H:74
virtual bool isVariableFloat() const =0
Returns true if the first variable referred is a float.
virtual int recursiveReadPosData(const float *vals, int nvals, int arrayPos) const =0
virtual bool isEmpty() const =0
Returns true if this entry and all below it are empty.
virtual bool less(const FFrEntryBase *obj) const =0
virtual const std::string & getDescription() const =0
virtual ~FFrEntryBase()
Empty destructor.
Definition: FFrEntryBase.H:49
FFrEntryBase(const FFrEntryBase &obj)
Copy constructor.
Definition: FFrEntryBase.H:38
FFrEntryBase & operator=(const FFrEntryBase &)=delete
Disable default assignment operator.
virtual int recursiveReadPosData(const double *vals, int nvals, int arrayPos) const =0
virtual const std::string & getType() const =0
bool isGlobal() const
Check if this entry is in global scope.
Definition: FFrEntryBase.H:107
virtual bool isVarRef() const
Definition: FFrEntryBase.H:113
void setOwner(FFrEntryBase *owner)
Defines the owner of this entry in the hierarchy.
Definition: FFrEntryBase.H:102
virtual bool hasDescription() const
Definition: FFrEntryBase.H:57
virtual bool isOG() const
Definition: FFrEntryBase.H:110
int readPositionedTimestepData(const T *values, int nvals) const
Reads all variable reference data in the hierarhcy under this entry.
Definition: FFrEntryBase.H:87
bool myGlobal
Global (extractor-level) or local (container level)
Definition: FFrEntryBase.H:140
virtual bool isIG() const
Definition: FFrEntryBase.H:112
virtual bool compare(const FFrEntryBase *) const
Definition: FFrEntryBase.H:130
virtual const std::vector< FFrEntryBase * > * getDataFields() const
Returns a pointer to the data fields if they are set, returns 0 if not.
Definition: FFrEntryBase.H:82
FFrEntryBase * myOwner
Parent of this entry in the RDB hierchy.
Definition: FFrEntryBase.H:139
virtual int recursiveReadPosData(const int *vals, int nvals, int arrayPos) const =0
Class holding the data of a Fedem results file.
Definition: FFrResultContainer.H:71