FEDEM Model Database  R8.0
Source code of the FEDEM model database
FmModelMemberBase.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 FM_MODEL_MEMBER_BASE_H
14 #define FM_MODEL_MEMBER_BASE_H
15 
16 #include <cstdio>
17 
18 #include "vpmDB/FmBase.H"
20 
22 
23 
34 {
38 
39 protected:
41  virtual void mainConnectedEvent() {}
43  virtual void mainDisconnectedEvent() {}
45  virtual void changedEvent() {}
46 
47 public:
49  enum Signal {
54  };
55 
57  void sendSignal(Signal sig);
60 
61  // From FFaListViewItem
62  const char* getItemName() const override { return this->getUITypeName(); }
63  std::string getItemDescr() const override { return this->getUserDescription(64); }
64  int getItemID() const final { return this->getID(); }
65  int getItemBaseID() const final { return this->getBaseID(); }
66  void getItemAssemblyPath(std::vector<int>& assID) const final;
67 
68 protected:
70  explicit FmModelMemberBase(bool isDummy = false);
71 
72  // From FmBase
73  bool cloneLocal(FmBase* obj, int depth) override;
74 
76  bool eraseOptions() override;
77 
78 public:
79  // From FmBase
80  void onMainConnected() final;
81  void onMainDisconnected() final;
82  void onMainAboutToDisconnect() final;
83 
85  void onChanged();
86 
88  virtual FmBase* duplicate() const { return NULL; }
89 
94  virtual bool interactiveErase() { return this->erase(); }
95 
97  virtual int printSolverEntry(FILE*) { return 0; }
99  void printID(FILE* myFile, bool withBaseID = true) const;
100 
102  int getBaseID() const { return myBaseID.getValue(); }
103 
105  static void resolveBaseIDProblems();
106 
108  bool setTag(const std::string& tag) { return myTag.setValue(tag); }
110  bool isTagged(const std::string& tag) const;
112  const std::string& getTag() const { return myTag.getValue(); }
113 
115  bool moveTo(FmSubAssembly* newAss);
116 
117 protected:
120 
121 private:
123  void setBaseID(int id) { myBaseID.setValue(id); }
124 
126  static std::vector<FmModelMemberBase*> baseIdProblems;
127 
128 public:
129  static bool ignoreBaseID;
130  static bool inInteractiveErase;
131 };
132 
133 #endif
Base class for list view items.
Base parent class for the model data structure entries.
#define Fmd_DB_HEADER_INIT()
Macro enabling type checking for a class.
Definition: FmTypeCheck.H:24
bool erase()
Deletes *this assuming it is heap-allocated.
Definition: FFaFieldContainer.C:39
bool setValue(const ValueT &newData, bool checkChanged=true)
Assigns a new value to the field.
Definition: FFaField.H:66
const ValueT & getValue() const
Returns a const reference to myData.
Definition: FFaField.H:56
Base class for list view items.
Definition: FFaListViewItem.H:31
Base class for every class that want to send or recieve.
Definition: FFaSwitchBoard.H:83
Base parent class for the model data structure entries.
Definition: FmBase.H:37
int getID() const
Returns the user ID of this object.
Definition: FmBase.H:66
virtual std::string getUserDescription(size_t maxLength=0) const
Returns the user-defined description of this object.
Definition: FmBase.C:371
virtual const char * getUITypeName() const
Returns the type name of this object for use in the GUI.
Definition: FmBase.C:409
Base class for all model data objects.
Definition: FmModelMemberBase.H:34
int getItemID() const final
Returns the user ID of this item.
Definition: FmModelMemberBase.H:64
void getItemAssemblyPath(std::vector< int > &assID) const final
Returns the sub-assembly ID path of this item.
Definition: FmModelMemberBase.C:57
Signal
Enumerator for database signals.
Definition: FmModelMemberBase.H:49
@ MODEL_MEMBER_FINISHED_DISCONNECTED
Definition: FmModelMemberBase.H:52
@ MODEL_MEMBER_DISCONNECTED
Definition: FmModelMemberBase.H:51
@ MODEL_MEMBER_CONNECTED
Definition: FmModelMemberBase.H:50
@ MODEL_MEMBER_CHANGED
Definition: FmModelMemberBase.H:53
void onMainDisconnected() final
Invokes call-backs after this object is removed from the database.
Definition: FmModelMemberBase.C:138
virtual void changedEvent()
Hook for class-dependent tasks when the object is updated.
Definition: FmModelMemberBase.H:45
static void resolveBaseIDProblems()
Resolves the conflicting base ID issues for baseIdProblems.
Definition: FmModelMemberBase.C:276
const char * getItemName() const override
Returns the name of this item.
Definition: FmModelMemberBase.H:62
bool cloneLocal(FmBase *obj, int depth) override
Clones the data fields of *obj into *this.
Definition: FmModelMemberBase.C:188
bool eraseOptions() override
Hook for class-specific tasks before deleting *this in erase().
Definition: FmModelMemberBase.C:167
FmModelMemberBase(bool isDummy=false)
Default constructor.
Definition: FmModelMemberBase.C:38
void sendSignal(Signal sig)
Broadcasts a database signal to trigger call-back invokations.
Definition: FmModelMemberBase.C:182
FFaField< std::string > myTag
Text string used for grouping objects.
Definition: FmModelMemberBase.H:119
const std::string & getTag() const
Returns a const reference to the tag assigned to this object.
Definition: FmModelMemberBase.H:112
void onMainConnected() final
Invokes call-backs after this object is inserted into the database.
Definition: FmModelMemberBase.C:79
std::string getItemDescr() const override
Returns the description of this item.
Definition: FmModelMemberBase.H:63
int getBaseID() const
Returns the base ID of this object.
Definition: FmModelMemberBase.H:102
static std::vector< FmModelMemberBase * > baseIdProblems
Objects with conflicting base ID encountered during model file parsing.
Definition: FmModelMemberBase.H:126
virtual FmBase * duplicate() const
Returns a connected copy of this object.
Definition: FmModelMemberBase.H:88
bool setTag(const std::string &tag)
Assigns a tag to this object.
Definition: FmModelMemberBase.H:108
void onMainAboutToDisconnect() final
Invokes call-backs before this object is removed from the database.
Definition: FmModelMemberBase.C:119
virtual bool interactiveErase()
Hook for class-dependent tasks for interactive deleting an object.
Definition: FmModelMemberBase.H:94
static bool inInteractiveErase
Set to true when interactive delete.
Definition: FmModelMemberBase.H:130
int getItemBaseID() const final
Returns the base ID of this item.
Definition: FmModelMemberBase.H:65
bool moveTo(FmSubAssembly *newAss)
Moves this object to another sub-assembly.
Definition: FmModelMemberBase.C:323
virtual void mainConnectedEvent()
Hook for class-dependent tasks when the object is connected.
Definition: FmModelMemberBase.H:41
void setBaseID(int id)
Assigns the base ID to this object.
Definition: FmModelMemberBase.H:123
void printID(FILE *myFile, bool withBaseID=true) const
Prints the ID of this object in the solver input file format.
Definition: FmModelMemberBase.C:63
static bool ignoreBaseID
Set to true when importing sub-assembly.
Definition: FmModelMemberBase.H:129
static FFaSwitchBoardConnector * getSignalConnector()
Returns the model database signal connector.
Definition: FmModelMemberBase.C:51
virtual void mainDisconnectedEvent()
Hook for class-dependent tasks when the object is disconnected.
Definition: FmModelMemberBase.H:43
virtual int printSolverEntry(FILE *)
Hoook for printing the solver input file entry for this object.
Definition: FmModelMemberBase.H:97
FFaNoCopyField< int > myBaseID
Base ID, unique over all object types.
Definition: FmModelMemberBase.H:118
void onChanged()
Invokes call-backs when this object updated.
Definition: FmModelMemberBase.C:149
bool isTagged(const std::string &tag) const
Returns true if this object has a tag assigned to it.
Definition: FmModelMemberBase.C:345
Base class for all sub-assembly objects.
Definition: FmSubAssembly.H:28