summaryrefslogtreecommitdiffabout
path: root/lib/sitespace.cc
Unidiff
Diffstat (limited to 'lib/sitespace.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/sitespace.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/sitespace.cc b/lib/sitespace.cc
new file mode 100644
index 0000000..0406d11
--- a/dev/null
+++ b/lib/sitespace.cc
@@ -0,0 +1,52 @@
1#ifdef USE_PCH
2 #include "pch.h"
3#else
4 #include <cassert>
5 #include "sitecing/sitespace.h"
6 #include "sitecing/sitecing_util.h"
7#endif
8
9namespace sitecing {
10
11 sitespace::sitespace(configuration& c)
12 : config(c), factory(c) { }
13
14 sitespace::~sitespace() {
15 for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) {
16 assert((*i)->chickens_used.empty());
17 delete *i;
18 }
19 }
20
21 so_component sitespace::fetch(const string& c,sitecing_interface* scif) {
22 execute_sentenced();
23 string sobase = normalize_path(c);
24 string sopath = factory.root_so+sobase+".so";
25 config_options *co_build = config.lookup_config(sobase,config_options::flag_build);
26 if( (!co_build) || co_build->build )
27 factory.make(sopath);
28 components_t::iterator i = components.find(sopath);
29 if(i!=components.end()) {
30 if(i->second->is_uptodate())
31 return so_component(i->second,scif);
32 if(i->second->chickens_used.empty()) {
33 delete i->second;
34 }else{
35 sentenced.push_back(i->second);
36 }
37 components.erase(i);
38 }
39 pair<components_t::iterator,bool> ins = components.insert(components_t::value_type(sopath,new component_so(sopath)));
40 return so_component(ins.first->second,scif);
41 }
42
43 void sitespace::execute_sentenced() {
44 for(sentenced_t::iterator i = sentenced.begin();i!=sentenced.end();++i) {
45 if((*i)->chickens_used.empty()) {
46 delete *i;
47 sentenced.erase(i);
48 }
49 }
50 }
51
52}