[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8a9e9f8 1/4: Move shared_ptr non-null asserti
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8a9e9f8 1/4: Move shared_ptr non-null assertion upstream to class cache_file_reads |
Date: |
Tue, 9 Aug 2016 14:30:26 +0000 (UTC) |
branch: master
commit 8a9e9f8b1cf9ec0b22b50fee51559676aac150af
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Move shared_ptr non-null assertion upstream to class cache_file_reads
---
cache_file_reads.hpp | 6 ++++++
database.cpp | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/cache_file_reads.hpp b/cache_file_reads.hpp
index b6b98b4..79478b3 100644
--- a/cache_file_reads.hpp
+++ b/cache_file_reads.hpp
@@ -24,6 +24,7 @@
#include "config.hpp"
+#include "assert_lmi.hpp"
#include "uncopyable_lmi.hpp"
#include <boost/filesystem/operations.hpp>
@@ -89,6 +90,7 @@ class file_cache
i->second.write_time = write_time;
}
+ LMI_ASSERT(i->second.data);
return i->second.data;
}
@@ -112,6 +114,10 @@ class cache_file_reads
using retrieved_type = typename file_cache<T>::retrieved_type;
public:
+ /// Return parent instance (constructed from file) via cache.
+ ///
+ /// Postcondition: returned pointer is not null; otherwise,
+ /// file_cache::retrieve_or_reload() throws.
static retrieved_type read_from_cache(std::string const& filename)
{
return file_cache<T>::instance().retrieve_or_reload(filename);
diff --git a/database.cpp b/database.cpp
index 822c5b0..4bd03c3 100644
--- a/database.cpp
+++ b/database.cpp
@@ -178,6 +178,8 @@ bool product_database::varies_by_state(e_database_key k)
const
namespace
{
/// Antediluvian database for static initialization.
+///
+/// Postcondition: returned pointer is not null; throws otherwise.
boost::shared_ptr<DBDictionary> antediluvian_db()
{
@@ -211,7 +213,6 @@ void product_database::initialize(std::string const&
product_name)
DBDictionary const& product_database::db() const
{
- LMI_ASSERT(db_);
return *db_;
}