aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/file-cache.hxx62
-rw-r--r--libbuild2/file-cache.ixx82
2 files changed, 105 insertions, 39 deletions
diff --git a/libbuild2/file-cache.hxx b/libbuild2/file-cache.hxx
index ca1799c..8d9d8dd 100644
--- a/libbuild2/file-cache.hxx
+++ b/libbuild2/file-cache.hxx
@@ -86,24 +86,28 @@ namespace build2
// without a close() call is treated as an unsuccessful write and the
// initialization can be attempted again.
//
- struct write
+ class write
{
- void close () {}
+ public:
+ void
+ close ();
};
// A cache entry read handle. During the lifetime of this object the
// filesystem entry can be opened for reading and read from.
//
- struct read
+ class read
{
- ~read () {}
+ public:
+ ~read ();
};
// A cache entry handle. When it is destroyed, a temporary entry is
// automatically removed from the filesystem.
//
- struct entry
+ class entry
{
+ public:
using path_type = build2::path;
bool temporary = true;
@@ -112,43 +116,34 @@ namespace build2
// entry handle.
//
const path_type&
- path () const {return path_;}
+ path () const;
// Initialization.
//
write
- init_new ()
- {
- return write ();
- }
+ init_new ();
void
- init_existing () {}
+ init_existing ();
// Reading.
//
read
- open ()
- {
- return read ();
- }
+ open ();
// Pinning.
//
void
- pin () {}
+ pin ();
void
- unpin () {}
+ unpin ();
- // NULL entry handle.
+ // NULL handle.
//
entry () = default;
- explicit operator bool () const
- {
- return !path_.empty ();
- }
+ explicit operator bool () const;
// Move-to-NULL-entry-only type.
//
@@ -170,20 +165,12 @@ namespace build2
// used to hint whether the entry is likely to be temporary or permanent.
//
entry
- create (path f, optional<bool> /*temporary*/)
- {
- return entry (move (f), true /* temporary */);
- };
+ create (path, optional<bool> temporary);
// A shortcut for creating and initializing an existing permanent entry.
//
entry
- create_existing (path f)
- {
- entry e (move (f), false /* temporary */);
- e.init_existing ();
- return e;
- };
+ create_existing (path);
// Return the compressed filesystem entry extension (with the leading dot)
// or empty string if no compression is used by this cache implementation.
@@ -193,15 +180,12 @@ namespace build2
// clean_extra()).
//
string
- compressed_extension (const char* = nullptr)
- {
- return string ();
- }
+ compressed_extension (const char* ext = nullptr);
+ // Implementation details.
+ //
explicit
- file_cache (scheduler&)
- {
- }
+ file_cache (scheduler&);
};
}
diff --git a/libbuild2/file-cache.ixx b/libbuild2/file-cache.ixx
index 259d348..6d73387 100644
--- a/libbuild2/file-cache.ixx
+++ b/libbuild2/file-cache.ixx
@@ -5,6 +5,61 @@
namespace build2
{
+ // file_cache::write
+ //
+ inline void file_cache::write::
+ close ()
+ {
+ }
+
+ // file_cache::read
+ //
+ inline file_cache::read::
+ ~read ()
+ {
+ }
+
+ // file_cache::entry
+ //
+ inline const path& file_cache::entry::
+ path () const
+ {
+ return path_;
+ }
+
+ inline file_cache::write file_cache::entry::
+ init_new ()
+ {
+ return write ();
+ }
+
+ inline void file_cache::entry::
+ init_existing ()
+ {
+ }
+
+ inline file_cache::read file_cache::entry::
+ open ()
+ {
+ return read ();
+ }
+
+ inline void file_cache::entry::
+ pin ()
+ {
+ }
+
+ inline void file_cache::entry::
+ unpin ()
+ {
+ }
+
+ inline file_cache::entry::
+ operator bool () const
+ {
+ return !path_.empty ();
+ }
+
inline file_cache::entry::
entry (path_type p, bool t)
: temporary (t), path_ (move (p))
@@ -35,4 +90,31 @@ namespace build2
}
return *this;
}
+
+ // file_cache
+ //
+ inline file_cache::entry file_cache::
+ create (path f, optional<bool>)
+ {
+ return entry (move (f), true /* temporary */);
+ }
+
+ inline file_cache::entry file_cache::
+ create_existing (path f)
+ {
+ entry e (move (f), false /* temporary */);
+ e.init_existing ();
+ return e;
+ }
+
+ inline string file_cache::
+ compressed_extension (const char*)
+ {
+ return string ();
+ }
+
+ inline file_cache::
+ file_cache (scheduler&)
+ {
+ }
}