-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathFECoreFactory.h
More file actions
120 lines (92 loc) · 4.17 KB
/
Copy pathFECoreFactory.h
File metadata and controls
120 lines (92 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "fecore_enum.h"
#include "FEParameterList.h"
//-----------------------------------------------------------------------------
//! Forward declaration of the FEModel class. All classes that register
//! with the framework take a pointer to FEModel as their constructor parameter.
class FEModel;
class FECoreBase;
//-----------------------------------------------------------------------------
//! The factory class contains the mechanism for instantiating a class.
class FECORE_API FECoreFactory : public FEParamContainer
{
public:
//! constructor
FECoreFactory(SUPER_CLASS_ID scid, const char* szclass, const char* szbase, const char* szalias, int nspec = -1);
//! virtual constructor
virtual ~FECoreFactory();
//! This is the function that the kernel will use to intantiate an object
FECoreBase* CreateInstance(FEModel* pfem) const;
public:
// return the class name
const char* GetClassName() const { return m_szclass; }
// return the base class name
const char* GetBaseClassName() const { return m_szbase; }
// return the type string identifier
const char* GetTypeStr() const { return m_szalias; }
//! return the super-class ID
SUPER_CLASS_ID GetSuperClassID() const { return m_scid; }
//! return the module name
unsigned int GetModuleID() const { return m_module; }
//! set the module name
void SetModuleID(unsigned int nid);
//! Get the spec number
int GetSpecID() const { return m_spec; }
//! Set the allocator ID
void SetAllocatorID(int alloc) { m_alloc_id = alloc; }
//! Get the allocator ID
int GetAllocatorID() const { return m_alloc_id; }
public:
//! derived classes implement this to create an instance of a class
virtual FECoreBase* Create(FEModel*) const = 0;
private:
const char* m_szclass; //!< class name
const char* m_szbase; //!< base class name
const char* m_szalias; //!< class alias string
int m_spec; //!< The max spec number for which this feature is defined (-1 is don't care)
unsigned int m_module; //!< ID of module this class belongs to
SUPER_CLASS_ID m_scid; //!< the super-class ID
int m_alloc_id; //!< allocator ID
};
//-----------------------------------------------------------------------------
//! Forward declarations of classes used by the domain factory
class FEDomain;
class FEMesh;
class FEMaterial;
class FEModel;
//-----------------------------------------------------------------------------
//! Creation of domains are a little more elaborate and deviate from the usual
//! factory methods.
class FECORE_API FEDomainFactory
{
public:
FEDomainFactory(){}
virtual ~FEDomainFactory(){}
virtual FEDomain* CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat) = 0;
};
#define FECORE_SPEC(major, minor) ((major << 8) + minor)
#define FECORE_SPEC_MAJOR(n) ((n) >> 8)
#define FECORE_SPEC_MINOR(n) ((n) & 0x0F)
// macro for tagging a feature as experimental (i.e. in development)
#define FECORE_EXPERIMENTAL int(0xFFFF)
#define FECORE_DEPRECATED int(0x300)