libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
Public 成员函数 | 静态 Public 成员函数 | Protected 成员函数 | 静态 Protected 成员函数 | 所有成员列表
libMesh::Factory< Base > 模板类 参考abstract

Factory class definition. 更多...

#include <factory.h>

类 libMesh::Factory< Base > 继承关系图:
[图例]

Public 成员函数

virtual ~Factory ()=default
 Destructor. 更多...
 
virtual std::unique_ptr< Base > create ()=0
 Create a Base class. 更多...
 

静态 Public 成员函数

static std::unique_ptr< Base > build (const std::string &name)
 Builds an object of type Base identified by name. 更多...
 

Protected 成员函数

 Factory (const std::string &name)
 Constructor. 更多...
 

静态 Protected 成员函数

static std::map< std::string,
Factory< Base > * > & 
factory_map ()
 Map from a name to a Factory<Base> * pointer. 更多...
 

详细描述

template<class Base>
class libMesh::Factory< Base >

Factory class definition.

作者
Benjamin S. Kirk
日期
2002 Handles name-based creation of objects.

在文件 factory.h46 行定义.

构造及析构函数说明

template<class Base >
libMesh::Factory< Base >::Factory ( const std::string &  name)
inlineprotected

Constructor.

Takes the name to be mapped.

在文件 factory.h116 行定义.

117 {
118  // Make sure we haven't already added this name
119  // to the map
120  libmesh_assert (!factory_map().count(name));
121 
122  factory_map()[name] = this;
123 }
static std::map< std::string, Factory< Base > * > & factory_map()
Map from a name to a Factory&lt;Base&gt; * pointer.
template<class Base>
virtual libMesh::Factory< Base >::~Factory ( )
virtualdefault

Destructor.

成员函数说明

template<class Base >
std::unique_ptr< Base > libMesh::Factory< Base >::build ( const std::string &  name)
inlinestatic

Builds an object of type Base identified by name.

在文件 factory.h129 行定义.

参考 libMesh::Factory< Base >::create() , 以及 libMesh::err.

130 {
131  // name not found in the map
132  if (!factory_map().count(name))
133  {
134  libMesh::err << "Tried to build an unknown type: " << name << std::endl;
135 
136  libMesh::err << "valid options are:" << std::endl;
137 
138  for (const auto & pr : factory_map())
139  libMesh::err << " " << pr.first << std::endl;
140 
141  libmesh_error_msg("Exiting...");
142  }
143 
144  Factory<Base> * f = factory_map()[name];
145  return std::unique_ptr<Base>(f->create());
146 }
static std::map< std::string, Factory< Base > * > & factory_map()
Map from a name to a Factory&lt;Base&gt; * pointer.
OStreamProxy err
template<class Base>
virtual std::unique_ptr<Base> libMesh::Factory< Base >::create ( )
pure virtual

Create a Base class.

Force this to be implemented later.

libMesh::FactoryImp< Derived, Base > 内被实现.

参考自 libMesh::Factory< Base >::build().

template<class Base>
static std::map<std::string, Factory<Base> *>& libMesh::Factory< Base >::factory_map ( )
staticprotected

Map from a name to a Factory<Base> * pointer.


该类的文档由以下文件生成: