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;
29 const string words =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_"
30 "abcdefghijklmnopqrstuvwxyz";
31 string construct =
"Construct";
33 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 || offset+lenconstruct == end_offset) {
39 offset += lenconstruct;
42 archs.insert(
string(s, offset+lenconstruct, end_offset - offset - lenconstruct));
51 namespace fs = boost::filesystem;
53 string libpath = (fs::path(p) / fs::path(
"lib" + lib +
SUFFIX)).
string();
57 std::ifstream f (libpath.c_str());
59 f.seekg(0, std::ios::end);
61 f.seekg(0, std::ios::beg);
62 s.assign((std::istreambuf_iterator<char>(f)),
63 std::istreambuf_iterator<char>());
70 for (set<string>::iterator it = archs.begin(); it != archs.end(); ++it) {
71 spec = p +
":" + lib +
":" + (*it);
83 namespace fs = boost::filesystem;
87 boost::system::error_code errc;
88 boost::system::error_code no_err;
90 fs::recursive_directory_iterator it(pth, errc);
91 fs::recursive_directory_iterator last;
92 for (; it != last; it.increment(errc)) {
100 string pthstr = pth.string();
101 bool irf = fs::is_regular_file(pth, errc);
102 if (errc != no_err || !irf) {
103 it.disable_recursion_pending();
104 if (it.depth() > 0) {
108 }
else if (fs::is_directory(pth, errc)) {
110 }
else if (!boost::algorithm::ends_with(pthstr,
SUFFIX)) {
113 string p = pth.parent_path().string();
114 string lib = pth.filename().string();
115 if (d.length() < p.length())
116 p = p.substr(d.length()+1, string::npos);
119 lib = lib.substr(3, lib.rfind(
".") - 3);
123 for (set<string>::iterator ls = libspecs.begin(); ls != libspecs.end(); ++ls) {
135 set<string> dirspecs;
137 for (vector<string>::iterator it = cycpath.begin(); it != cycpath.end(); ++it) {
139 for (set<string>::iterator ds = dirspecs.begin(); ds != dirspecs.end(); ++ds) {
156 std::set<std::string>::iterator it;
158 for (it = specs.begin(); it != specs.end(); ++it) {
168 root[
"specs"] = spec;
169 root[
"annotations"] = anno;
170 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.