[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 7b72364 3/4: Sequester implementation (class
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 7b72364 3/4: Sequester implementation (class template file_cache) in a namespace |
Date: |
Tue, 9 Aug 2016 14:30:26 +0000 (UTC) |
branch: master
commit 7b723648c325fa958dde713ea7ff9bba87146685
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Sequester implementation (class template file_cache) in a namespace
Move implementation into namespace "detail". This convention is well
known because many header-only boost libraries use it, so it should be
clear enough that this namespace is to be regarded as opaque, despite
the actual visibility of its contents.
As an alternative, class template file_cache might have been nested in
class template cache_file_reads. That would create an actual barrier.
However, writing everything inline would make the code harder to read,
while implementing the inner class out of line would require tricky
forward declarations.
---
cache_file_reads.hpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/cache_file_reads.hpp b/cache_file_reads.hpp
index ac64973..0cebbe9 100644
--- a/cache_file_reads.hpp
+++ b/cache_file_reads.hpp
@@ -35,6 +35,8 @@
#include <string>
#include <utility> // std::make_pair()
+namespace detail
+{
/// Cache of class T instances constructed from files.
///
/// Motivation: It is costly to deserialize objects from xml, so cache
@@ -103,6 +105,7 @@ class file_cache
std::map<std::string,record> cache_;
};
+} // namespace detail
/// Mixin to cache parent instances constructed from files.
///
@@ -111,7 +114,7 @@ class file_cache
template<typename T>
class cache_file_reads
{
- using retrieved_type = typename file_cache<T>::retrieved_type;
+ using retrieved_type = typename detail::file_cache<T>::retrieved_type;
public:
/// Return parent instance (constructed from file) via cache.
@@ -121,7 +124,7 @@ class cache_file_reads
static retrieved_type read_via_cache(std::string const& filename)
{
- return file_cache<T>::instance().retrieve_or_reload(filename);
+ return detail::file_cache<T>::instance().retrieve_or_reload(filename);
}
};