Branch data Line data Source code
1 : : #ifndef MESHKIT_MESH_OP_SET_HPP
2 : : #define MESHKIT_MESH_OP_SET_HPP
3 : :
4 : : #include <vector>
5 : :
6 : : namespace MeshKit
7 : : {
8 : :
9 : : class MeshOpProxy;
10 : :
11 : : /**\brief Maintain global, singletin list of registered MeshOps
12 : : *
13 : : * This class implements the list of registered MeshOps. It
14 : : * uses the singleton pattern to provide a single global list
15 : : * while avoiding issues with order of initialization of static
16 : : * objects.
17 : : *
18 : : * This class is intended only for internal use in \c MKCore. Access
19 : : * to this data maintained by this class should be done through
20 : : * static methods in the \c MKCore class.
21 : : */
22 [ + - ][ + + ]: 228 : class MeshOpSet
23 : : {
24 : : public:
25 : : /**\brief Get singleton instance */
26 : : static MeshOpSet& instance();
27 : :
28 : : /**\brief Register a mesh op.
29 : : *
30 : : * Register a new MeshOp. Will fail upon duplicate
31 : : * names unless proxy pointer is also the same (duplicate
32 : : * registration).
33 : : *
34 : : *\param proxy Proxy for MeshOp sub-class.
35 : : */
36 : : void register_mesh_op( MeshOpProxy* proxy );
37 : :
38 : : /**\brief Type of list returned by reference from member methods */
39 : : typedef std::vector<MeshOpProxy*> OpList;
40 : :
41 : : /**\brief Type of iterator to use with /c OpList */
42 : : typedef OpList::const_iterator iterator;
43 : :
44 : : /**\brief Get list of all MeshOps that can be used to
45 : : * generate mesh entities of the specified dimension.
46 : : *\param dimension Dimension of entity to be meshed
47 : : *\return List of MeshOps that can mesh entities of the specified dimesion.
48 : : */
49 : 12 : const OpList& mesh_ops( unsigned dimension ) const
50 : 12 : { return dimMeshOps[dimension]; }
51 : :
52 : : /**\brief Get list of all mesh ops
53 : : *
54 : : *\return List of all registered MeshOps
55 : : */
56 : 1 : const OpList& mesh_ops() const
57 : 1 : { return allMeshOps; }
58 : :
59 : : /**\brief Get MeshOpProxy by name
60 : : *
61 : : * Get MeshOpProxy by name. Throws exception if not found.
62 : : *
63 : : *\param name MeshOp class name.
64 : : *\return MeshOpProxy for MeshOp with the passed name
65 : : */
66 : : MeshOpProxy* mesh_op( const char* name ) const;
67 : :
68 : : /**\brief Get index of MeshOpProxy
69 : : *
70 : : * Get index of MeshOpProxy. Throws exception if not found.
71 : : *
72 : : *\param name MeshOp class name.
73 : : *\return index of MeshOpProxy for MeshOp with the passed name
74 : : */
75 : : unsigned index( const char* name ) const;
76 : :
77 : : /**\brief Get MeshOpProxy by index
78 : : *
79 : : * Get MeshOpProxy by index. Throws exception if not found.
80 : : *
81 : : *\param index MeshOp index.
82 : : *\return the MeshOpProxy
83 : : */
84 : : MeshOpProxy* mesh_op( unsigned index ) const;
85 : :
86 : : private:
87 : :
88 : : /**\brief Private constructor for singleton pattern */
89 : : MeshOpSet();
90 : :
91 : : /**\brief Get MeshOpProxy by name
92 : : *
93 : : * Returns \c allMeshOps.end() if not found.
94 : : *
95 : : *\param name MeshOp class name.
96 : : *\return iterator into allMeshOps
97 : : */
98 : : iterator mesh_op_no_throw( const char* name ) const;
99 : :
100 : :
101 : : /**\brief List of all registered MeshOps */
102 : : OpList allMeshOps;
103 : : /**\brief Lists of all registered indexed by dimension of generated entities */
104 : : OpList dimMeshOps[4];
105 : : };
106 : :
107 : : } // namespace MeshKit
108 : :
109 : : #endif // #ifdef MESHKIT_MESH_OP_SET_HPP
|