b2api
B2000++ API Reference Manual, VERSION 4.6
 
Loading...
Searching...
No Matches
b2module.H
1//------------------------------------------------------------------------
2// b2module.H --
3//
4//
5// written by Mathias Doreille
6//
7// Copyright (c) 2004-2012 SMR Engineering & Development SA
8// 2502 Bienne, Switzerland
9//
10// All Rights Reserved. Proprietary source code. The contents of
11// this file may not be disclosed to third parties, copied or
12// duplicated in any form, in whole or in part, without the prior
13// written permission of SMR.
14//------------------------------------------------------------------------
15
16#ifndef __B2MODULE_H__
17#define __B2MODULE_H__
18
19// This text now in the B2000++ programming manual
20
86#include <dlfcn.h>
87
88#include <map>
89#include <ostream>
90#include <sstream>
91#include <string>
92
93#include "b2ppconfig.h"
94#include "utils/b2exception.H"
95
96struct _object;
97typedef struct _object PyObject;
98
99namespace b2000 {
100
101class Module;
102class ObjectType;
103
104inline std::ostream& operator<<(std::ostream& o, const Module& m);
105
109class Module {
110public:
111 Module(const std::string& name_, Module* parent_, const char* doc_ = nullptr);
112
114 std::string get_name() const;
115
119 std::string get_full_name(char separator = '.') const;
120
135 void set_object_type(
136 ObjectType* object_type, const std::string& name_,
137 const StringList& aliases = StringList(), const std::string& suffix = "");
138
149 ObjectType* get_object_type(const std::string& name_) const;
150
157 Module* get_module(const std::string& name_) const;
158
159 PyObject* init_python_module();
160
161 void print_list(std::ostream& out, const std::string& prefix = "") const;
162
163 const std::map<std::string, ObjectType*>& get_object_types_list() const {
164 return object_types_list;
165 }
166
167private:
168 const std::string name;
169 Module* parent;
170 typedef std::map<std::string, ObjectType*> object_types_list_t;
171 object_types_list_t object_types_list;
172 typedef std::map<std::string, Module*> modules_list_t;
173 modules_list_t modules_list;
174 const char* doc;
175 PyObject* python_module;
176
177 class Link;
178 friend class Link;
179
180 class Link {
181 public:
182 Link() : initialised(false) {}
183 bool initialised;
184 object_types_list_t object_types_list;
185 modules_list_t modules_list;
186 };
187 typedef std::map<Module*, Link> module_link_t;
188 static module_link_t* module_link_p;
189
190 static std::string get_python_name(const std::string& name_);
191};
192
193inline std::ostream& operator<<(std::ostream& o, const Module& m) { return o << m.get_full_name(); }
194
195extern Module b2000_module;
196
197} // namespace b2000
198
199#endif
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32