Thea
ArpackPlugin.cpp
1 //============================================================================
2 //
3 // This file is part of the Thea toolkit.
4 //
5 // This software is distributed under the BSD license, as detailed in the
6 // accompanying LICENSE.txt file. Portions are derived from other works:
7 // their respective licenses and copyright information are reproduced in
8 // LICENSE.txt and/or in the relevant source files.
9 //
10 // Author: Siddhartha Chaudhuri
11 // First version: 2009
12 //
13 //============================================================================
14 
15 #include "ArpackPlugin.hpp"
16 #include "ArpackEigenSolver.hpp"
17 
18 namespace Thea {
19 
20 static Algorithms::ArpackPlugin * plugin = nullptr;
21 
23 extern "C" THEA_ARPACK_API IPlugin *
25 {
26  plugin = new Algorithms::ArpackPlugin(registry_);
27  return plugin;
28 }
29 
31 extern "C" THEA_ARPACK_API void
33 {
34  delete plugin;
35 }
36 
37 namespace Algorithms {
38 
39 static char const * ARPACK_PLUGIN_NAME = "ARPACK EigenSolver";
40 static char const * ARPACK_EIGENSOLVER_NAME = "ARPACK";
41 
43 : registry(registry_), factory(nullptr), started(false)
44 {
45  alwaysAssertM(registry, std::string(ARPACK_PLUGIN_NAME) + ": Factory registry must be non-null");
46 }
47 
49 {
50  uninstall();
51 }
52 
53 char const *
55 {
56  return ARPACK_PLUGIN_NAME;
57 }
58 
59 void
61 {}
62 
63 void
65 {
66  if (!started)
67  {
68  if (!factory)
69  factory = new ArpackEigenSolverFactory;
70 
71  registry->addEigenSolverFactory(ARPACK_EIGENSOLVER_NAME, factory);
72  started = true;
73  }
74 }
75 
76 void
78 {
79  if (started)
80  {
81  factory->destroyAllEigenSolvers();
82 
83  registry->removeEigenSolverFactory(ARPACK_EIGENSOLVER_NAME);
84  started = false;
85  }
86 }
87 
88 void
90 {
91  shutdown(); // not currently dependent on presence of other plugins
92 
93  if (factory)
94  {
95  delete factory;
96  factory = nullptr;
97  }
98 }
99 
100 } // namespace Algorithms
101 
102 } // namespace Thea
Root namespace for the Thea library.
void startup()
Startup routine for the plugin.
An ARPACK-based eigensolver plugin.
void uninstall()
Uninstallation routine for the plugin.
ArpackPlugin(IFactoryRegistry *registry_)
Constructor.
char const * getName() const
Get the name of the plugin.
Factory for creating ARPACK eigensolvers.
virtual void removeEigenSolverFactory(char const *name)=0
Unregister an eigensolver factory.
int8 destroyAllEigenSolvers()
Destroy all eigensolvers created with this factory.
void shutdown()
Shutdown routine for the plugin.
void install()
Installation routine for the plugin.
Interface provided to DLL's for registering rendersystem factories etc.
Definition: IPlugin.hpp:91
void dllStopPlugin()
DLL stop routine.
IPlugin * dllStartPlugin(IFactoryRegistry *registry_)
DLL start routine.
virtual void addEigenSolverFactory(char const *name, Algorithms::IEigenSolverFactory *factory)=0
Register an eigensolver factory.
void alwaysAssertM(CondT const &test, MessageT const &msg)
Check if a test condition is true, and immediately abort the program with an error code if not...
Definition: Common.hpp:66