Lem
The Lem Plugin
lemFactory.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
25 #ifndef _GEMA_LEM_FACTORY_H_
26 #define _GEMA_LEM_FACTORY_H_
27 
28 #include <gmSimulationData.h>
29 #include <gmPluginLoader.h>
30 #include <gmPluginInfo.h>
31 #include <QObject>
32 #include <gmPluginObjectFactory.h>
33 #include <gmpFemPhysicsCommonMaterial.h>
34 
35 #include "lemMechanicalPhysics.h"
36 #include "lemMechanicalTBeam.h"
37 #include "lemMaterialElastic.h"
38 #include "lemVersion.h"
39 
40 
43 {
44  Q_OBJECT
45  Q_PLUGIN_METADATA(IID GmPluginObjectFactoryInterfaceIID)
46  Q_INTERFACES(GmPluginObjectFactory)
47 
48 public:
51 
53  const GmpFemPhysicsCommonMaterialFactory* matFactory(GmSimulationData* simulation)
54  {
55  static GmpFemPhysicsCommonMaterialFactory matFactory;
56 
57  // If this is the first time that instance() is called, lets register material types
58  if(matFactory.numMaterialTypes() == 0)
59  {
60  const GmPluginInfo* ourInfo = simulation->loader()->pluginInfo("Lem");
61  assert(ourInfo);
62  const QVariantMap& map = ourInfo->attributes().value("constants").value<QVariantMap>().value("materialModels").value<QVariantMap>();
63 
64  matFactory.registerMaterial(map.value("elastic").toInt(), "elastic", LemMaterialElastic::instance, true);
65 
66  assert(matFactory.checkTypeMap());
67  }
68 
69  return &matFactory;
70  }
71 
72  // See comments on the base class method declaration
73  virtual GmPluginObject* instance(QString category, QString objType, GmSimulationData* simulation,
74  QString id, QString description)
75  {
76  assert(category == GM_PLUGIN_PHYSICS);
77 
78  // Instance the requested physics object
79  if (objType == "TimoshenkoPS")
80  return new LemMechanicalTBeam("TimoshenkoPS", simulation, id, description, matFactory(simulation), logger());
81  if (objType == "TimoshenkoPE")
82  return new LemMechanicalTBeam("TimoshenkoPE", simulation, id, description, matFactory(simulation), logger());
83  if (objType == "Timoshenko3D")
84  return new LemMechanicalTBeam("Timoshenko3D", simulation, id, description, matFactory(simulation), logger());
85  else if (objType == "Spring")
86  return NULL;
87  else
88  return NULL;
89  }
90 
92  virtual const QStringList& versionInfo() const { return LemVersionInfo(); }
93 
95  virtual const QStringList& depVersionInfo() const { return LemRevisionDependencies(); }
96 };
97 
98 #endif
Declaration of the LemMechanicalTBeam class.
const GmpFemPhysicsCommonMaterialFactory * matFactory(GmSimulationData *simulation)
Returns the single material factory used by created physics.
Definition: lemFactory.h:53
const GmLogCategory & logger()
const QVariantMap & attributes() const
Declaration of the LemMechanicalPhysics class.
GmPluginInfo * pluginInfo(QString pluginName) const
Declaration of the LemMaterialElastic class.
GmPluginLoader * loader() const
LemFactory()
Default constructor.
Definition: lemFactory.h:50
Basic class for Timoshenko Beam plugin object.
Definition: lemMechanicalTBeam.h:34
virtual const QStringList & versionInfo() const
Retuns version information for the plugin. See comments on the base class.
Definition: lemFactory.h:92
virtual const QStringList & depVersionInfo() const
Retuns dependency version information for the plugin. See comments on the base class.
Definition: lemFactory.h:95
Implementation of the MechanicalFemPhysics factory plugin.
Definition: lemFactory.h:42
static GmpFemPhysicsCommonMaterial * instance(GmSimulationData *simulation, int typeIndex, QString typeName, const GmLogCategory &logger)
A "factory" function used to register the material with the physics material factory.
Definition: lemMaterialElastic.h:57
#define GmPluginObjectFactoryInterfaceIID