3#include <boost/filesystem.hpp>
4#include <boost/algorithm/string.hpp>
5#include <boost/algorithm/string/predicate.hpp>
13#include DYNAMICLOADLIB
15namespace fs = boost::filesystem;
42 std::vector<std::string>
strs;
44 if (
strs.size() != 3) {
54 std::string
s =
str();
55 boost::replace_all(
s,
"/",
"_");
56 boost::replace_all(
s,
"-",
"_");
57 boost::replace_all(
s,
":",
"_");
58 boost::replace_all(
s,
".",
"_");
63 return (fs::path(path_) / fs::path(
"lib" + lib_ +
SUFFIX)).string();
67 return path_ +
":" + lib_ +
":" + agent_;
70std::map<std::string, DynamicModule*> DynamicModule::modules_;
71std::map<std::string, AgentCtor*> DynamicModule::man_ctors_;
74 if (man_ctors_.count(spec.
str()) > 0) {
78 }
else if (modules_.count(spec.
str()) == 0) {
80 modules_[spec.
str()] =
dyn;
85 if (boost::starts_with(
dyn->path(),
"<py>")) {
91 a =
dyn->ConstructInstance(ctx);
108 std::map<std::string, DynamicModule*>::iterator
it;
109 for (
it = modules_.begin();
it != modules_.end();
it++) {
110 it->second->CloseLibrary();
127 : module_library_(0),
130 if (boost::starts_with(path_,
"<py>")) {
134 ctor_name_ =
"Construct" + spec.
agent();
139Agent* DynamicModule::ConstructInstance(
Context* ctx) {
a holding class for information related to a TradeExecutor
The abstract base class used by all types of agents that live and interact in a simulation.
A simulation context provides access to necessary simulation-global functions and state.
static void CloseAll()
Closes all statically loaded dynamic modules.
static bool IsPyAgent(AgentSpec spec)
Tests that an agent spec is for a Python Agent.
DynamicModule()
Do-nothing constructor.
static Agent * Make(Context *ctx, AgentSpec spec)
Returns a newly constructed agent for the given module spec.
static bool Exists(AgentSpec spec)
Tests that an agent spec really exists.
std::string path()
The path to the module's shared object library.
static std::string FindModule(std::string path)
Returns the full path to a module by searching through default install and CYCLUS_PATH directories.
A generic mechanism to manually manage exceptions.
A class for extracting information from a given XML parser.
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
For values that are too big, too small, etc.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
void ClearPyAgentRefs(void)
Removes all Python agents from the internal cache.
Agent * MakePyAgent(std::string lib, std::string agent, void *ctx)
Finds a Python module and returns an agent pointer from it.
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters