aboutsummaryrefslogtreecommitdiff
path: root/src/cache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.cpp')
-rw-r--r--src/cache.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/cache.cpp b/src/cache.cpp
index d6269e3..8d6a91e 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -5,60 +5,60 @@
5using namespace Bu; 5using namespace Bu;
6 6
7Cache::Cache() : 7Cache::Cache() :
8 bCacheChanged( false ), 8 bCacheChanged( false ),
9 bIsLoaded( false ) 9 bIsLoaded( false )
10{ 10{
11} 11}
12 12
13Cache::~Cache() 13Cache::~Cache()
14{ 14{
15 save(); 15 save();
16} 16}
17 17
18void Cache::bind( const Bu::String &sCacheFile ) 18void Cache::bind( const Bu::String &sCacheFile )
19{ 19{
20 this->sCacheFile = sCacheFile; 20 this->sCacheFile = sCacheFile;
21 load(); 21 load();
22} 22}
23 23
24void Cache::load() 24void Cache::load()
25{ 25{
26 if( bIsLoaded ) 26 if( bIsLoaded )
27 return; 27 return;
28 28
29 try 29 try
30 { 30 {
31 Bu::File fIn( sCacheFile, Bu::File::Read ); 31 Bu::File fIn( sCacheFile, Bu::File::Read );
32 Bu::Archive ar( fIn, Bu::Archive::load ); 32 Bu::Archive ar( fIn, Bu::Archive::load );
33 33
34 ar >> hRequires >> hVariables; 34 ar >> hRequires >> hVariables;
35 } 35 }
36 catch(...) { } 36 catch(...) { }
37 37
38 bIsLoaded = true; 38 bIsLoaded = true;
39} 39}
40 40
41void Cache::save() 41void Cache::save()
42{ 42{
43 if( !bIsLoaded ) 43 if( !bIsLoaded )
44 return; 44 return;
45 if( bCacheChanged == false ) 45 if( bCacheChanged == false )
46 return; 46 return;
47 47
48 Bu::File fIn( sCacheFile, Bu::File::WriteNew ); 48 Bu::File fIn( sCacheFile, Bu::File::WriteNew );
49 Bu::Archive ar( fIn, Bu::Archive::save ); 49 Bu::Archive ar( fIn, Bu::Archive::save );
50 50
51 ar << hRequires << hVariables; 51 ar << hRequires << hVariables;
52} 52}
53 53
54StrList Cache::getRequires( const Bu::String &sOutput ) 54StrList Cache::getRequires( const Bu::String &sOutput )
55{ 55{
56 return hRequires.get( sOutput ); 56 return hRequires.get( sOutput );
57} 57}
58 58
59void Cache::setRequires( const Bu::String &sOutput, StrList lReqs ) 59void Cache::setRequires( const Bu::String &sOutput, StrList lReqs )
60{ 60{
61 hRequires.insert( sOutput, lReqs ); 61 hRequires.insert( sOutput, lReqs );
62 bCacheChanged = true; 62 bCacheChanged = true;
63} 63}
64 64