CYCLUS
Loading...
Searching...
No Matches
windows_helper_functions.h
Go to the documentation of this file.
1// This is the dynamic loading implementation for WINDOWS machines
2#ifndef CYCLUS_SRC_WINDOWS_HELPER_FUNCTIONS_H_
3#define CYCLUS_SRC_WINDOWS_HELPER_FUNCTIONS_H_
4
5#include <windows.h>
6
7#include "error.h"
8#include "platform.h"
9
10namespace cyclus {
11
12// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13void DynamicModule::OpenLibrary() {
14 module_library_ = LoadLibrary(path_.c_str());
15
16 if (!module_library_) {
17 std::string err_msg = "Unable to load agent shared object file: ";
18 err_msg += ". Error code is: ";
20 throw IOError(err_msg);
21 }
22}
23
24// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25void DynamicModule::SetConstructor() {
26 ctor_ = (AgentCtor*)
27 GetProcAddress(module_library_, ctor_name_.c_str());
28
29 if (!ctor_) {
30 std::stringstream ss;
31 std::string agent = ctor_name_;
32 agent.erase(0, 9); // len(Construct) == 9
33 ss << "Could not find agent " << agent << " in module library "
34 << path_.c_str() << " (" << GetLastError() << ").";
35 throw IOError(ss.str());
36 }
37}
38
39// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40void DynamicModule::CloseLibrary() {
41 if (module_library_) {
42 FreeLibrary(module_library_);
43 }
44}
45
46} // namespace cyclus
47
48#endif // CYCLUS_SRC_WINDOWS_HELPER_FUNCTIONS_H_
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
Agent * AgentCtor(Context *)
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters