Shiokaze Framework
A research-oriented fluid solver for computer graphics
module.h
Go to the documentation of this file.
1 /*
2 ** module.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on Feb 3, 2017.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
25 //
26 #ifndef SHKZ_MODULE_H
27 #define SHKZ_MODULE_H
28 //
29 #include <shiokaze/core/credit.h>
31 #include <iostream>
32 #include <memory>
33 #include <cassert>
34 #include "messageable.h"
35 //
37 //
39 #define DEFINE_QUICK_ALLOC_MODULE(CLASS_T,ARG_NAME,DESCRIPTION) \
42  ARGUMENT_NAME(ARG_NAME) \
43  static std::unique_ptr<CLASS_T> quick_alloc_module( configuration &config, std::string name ) { \
44  return unique_alloc_module<CLASS_T>(config,ARG_NAME,name,DESCRIPTION); \
45  }
46 //
49 class module : public credit, public messageable {
50 public:
55  module ();
60  virtual ~module();
67  virtual std::string get_module_name() const { return std::string(); }
74  static std::string module_libpath( std::string module_name );
89  static module * alloc_module( configuration &config, std::string arg_name, std::string default_module_name, std::string description );
98  static module * alloc_module( std::string path );
105  static unsigned close_all_handles ();
120  template <class T> static std::unique_ptr<T> unique_alloc_module( configuration &config, std::string arg_name, std::string default_module_name, std::string description ) {
121  auto ptr = dynamic_cast<T*>(alloc_module(config,arg_name,default_module_name,description));
122  assert(ptr);
123  return std::unique_ptr<T>(ptr);
124  }
131  static unsigned count_open_modules();
132  //
133 private:
134  std::string m_path;
135  module( const module & ) = delete;
136  module& operator=( const module & ) = delete;
137 };
138 //
139 /******** Your binary should include the following function **********
140 //
141 extern "C" module * create_instance();
142 //
143 **********************************************************************/
144 //
146 //
147 #endif
module::module
module()
Default constructor for module.
module::count_open_modules
static unsigned count_open_modules()
Count all the open modules.
credit.h
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
module::alloc_module
static module * alloc_module(configuration &config, std::string arg_name, std::string default_module_name, std::string description)
Automatically reads the parameter "arg_name" to fetch the name for the library, and allocate the libr...
module::get_module_name
virtual std::string get_module_name() const
Get the module name.
Definition: module.h:67
module
Module class.
Definition: module.h:49
module::~module
virtual ~module()
Default destructor for module.
module::unique_alloc_module
static std::unique_ptr< T > unique_alloc_module(configuration &config, std::string arg_name, std::string default_module_name, std::string description)
Allocate the module and cast to the a specified class T.
Definition: module.h:120
configuration.h
credit
Class that defines the name, argument name, author's name, email address, date and the version of the...
Definition: credit.h:47
configuration
Class that controls the settings of the program.
Definition: configuration.h:39
messageable
Message class.
Definition: messageable.h:36
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
messageable.h
module::close_all_handles
static unsigned close_all_handles()
Close all the handles that are still unloaded.
module::module_libpath
static std::string module_libpath(std::string module_name)
Get the path to the dynamic library. e.g., "mylib" -> "symlink-public/lib/libshiokaze_mylib....