8#include <boost/filesystem.hpp>
9#include <boost/foreach.hpp>
10#include <boost/algorithm/string.hpp>
11#include <boost/algorithm/string/predicate.hpp>
26 std::set<string> archs;
28 size_t end_offset = 0;
30 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_"
31 "abcdefghijklmnopqrstuvwxyz";
32 string construct =
"Construct";
33 if (
SUFFIX ==
".dylib") construct =
"_Construct";
34 size_t lenconstruct = construct.length();
35 while ((offset = s.find(construct, offset)) != string::npos) {
36 end_offset = s.find_first_not_of(words, offset + lenconstruct);
37 if (words.find(s[offset - 1]) != string::npos ||
38 offset + lenconstruct == end_offset) {
40 offset += lenconstruct;
44 string(s, offset + lenconstruct, end_offset - offset - lenconstruct));
53 namespace fs = boost::filesystem;
55 string libpath = (fs::path(p) / fs::path(
"lib" + lib +
SUFFIX)).
string();
59 std::ifstream f(libpath.c_str());
61 f.seekg(0, std::ios::end);
63 f.seekg(0, std::ios::beg);
64 s.assign((std::istreambuf_iterator<char>(f)),
65 std::istreambuf_iterator<char>());
72 for (set<string>::iterator it = archs.begin(); it != archs.end(); ++it) {
73 spec = p +
":" + lib +
":" + (*it);
85 namespace fs = boost::filesystem;
89 boost::system::error_code errc;
90 boost::system::error_code no_err;
92 fs::recursive_directory_iterator it(pth, errc);
93 fs::recursive_directory_iterator last;
94 for (; it != last; it.increment(errc)) {
102 string pthstr = pth.string();
103 bool irf = fs::is_regular_file(pth, errc);
104 if (errc != no_err || !irf) {
105 it.disable_recursion_pending();
106 if (it.depth() > 0) {
110 }
else if (fs::is_directory(pth, errc)) {
112 }
else if (!boost::algorithm::ends_with(pthstr,
SUFFIX)) {
115 string p = pth.parent_path().string();
116 string lib = pth.filename().string();
117 if (d.length() < p.length())
118 p = p.substr(d.length() + 1, string::npos);
121 lib = lib.substr(3, lib.rfind(
".") - 3);
126 for (set<string>::iterator ls = libspecs.begin(); ls != libspecs.end();
139 set<string> dirspecs;
141 for (vector<string>::iterator it = cycpath.begin(); it != cycpath.end();
144 for (set<string>::iterator ds = dirspecs.begin(); ds != dirspecs.end();
162 std::set<std::string>::iterator it;
164 for (it = specs.begin(); it != specs.end(); ++it) {
174 root[
"specs"] = spec;
175 root[
"annotations"] = anno;
176 root[
"schema"] = schm;
Value & append(const Value &value)
Append value to array at the end.
The abstract base class used by all types of agents that live and interact in a simulation.
virtual Json::Value annotations()
Returns an agent's json annotations for all state variables and any other information the developer w...
virtual std::string schema()
Returns an agent's xml rng schema for initializing from input files.
A simulation context provides access to necessary simulation-global functions and state.
void DelAgent(Agent *m)
Destructs and cleans up m (and it's children recursively).
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.
static std::string FindModule(std::string path)
Returns the full path to a module by searching through default install and CYCLUS_PATH directories.
static const std::vector< std::string > cyclus_path()
for failed reading/writing to files, network connections, etc..
Collects and manages output data generation for the cyclus core and agents during a simulation.
Controls simulation timestepping and inter-timestep phases.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
std::set< std::string > DiscoverSpecsInDir(std::string d)
Discover archetype specifications that live recursively in modules in a dir.
std::set< std::string > DiscoverSpecsInCyclusPath()
Discover archetype specifications that live recursively in CYCLUS_PATH directories.
Json::Value DiscoverMetadataInCyclusPath()
Discover archetype metadata in cyclus path.
std::set< std::string > DiscoverArchetypes(const std::string s)
This function returns a vector of archetype names in a given string that is the binary represnetation...
std::set< std::string > DiscoverSpecs(std::string p, std::string lib)
Discover archetype specifications for a path and library.