diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/address_validator.cc | 4 | ||||
-rw-r--r-- | cpp/src/metadata_query_task.cc | 2 | ||||
-rw-r--r-- | cpp/src/ondemand_supplier.cc (renamed from cpp/src/metadata_loader.cc) | 28 | ||||
-rw-r--r-- | cpp/src/ondemand_supplier.h (renamed from cpp/src/metadata_loader.h) | 16 | ||||
-rw-r--r-- | cpp/src/validation_task.h | 2 |
5 files changed, 26 insertions, 26 deletions
diff --git a/cpp/src/address_validator.cc b/cpp/src/address_validator.cc index 39ff651..1092f8c 100644 --- a/cpp/src/address_validator.cc +++ b/cpp/src/address_validator.cc @@ -23,8 +23,8 @@ #include <cstddef> #include <string> -#include "metadata_loader.h" #include "metadata_query_task.h" +#include "ondemand_supplier.h" #include "retriever.h" #include "rule.h" #include "validation_task.h" @@ -35,7 +35,7 @@ namespace addressinput { AddressValidator::AddressValidator(const std::string& validation_data_url, const Downloader* downloader, Storage* storage) - : own_supplier_(new MetadataLoader( + : own_supplier_(new OndemandSupplier( new Retriever(validation_data_url, downloader, storage))), supplier_(own_supplier_.get()) { assert(supplier_ != NULL); diff --git a/cpp/src/metadata_query_task.cc b/cpp/src/metadata_query_task.cc index ed5483c..13b827c 100644 --- a/cpp/src/metadata_query_task.cc +++ b/cpp/src/metadata_query_task.cc @@ -23,7 +23,7 @@ #include <string> #include "lookup_key.h" -#include "metadata_loader.h" +#include "ondemand_supplier.h" namespace i18n { namespace addressinput { diff --git a/cpp/src/metadata_loader.cc b/cpp/src/ondemand_supplier.cc index a86df94..38b4e7c 100644 --- a/cpp/src/metadata_loader.cc +++ b/cpp/src/ondemand_supplier.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "metadata_loader.h" +#include "ondemand_supplier.h" #include <algorithm> #include <cassert> @@ -36,20 +36,20 @@ namespace i18n { namespace addressinput { -MetadataLoader::MetadataLoader(const Retriever* retriever) +OndemandSupplier::OndemandSupplier(const Retriever* retriever) : retriever_(retriever) { assert(retriever_ != NULL); } -MetadataLoader::~MetadataLoader() { +OndemandSupplier::~OndemandSupplier() { for (std::map<std::string, const Rule*>::const_iterator it = rule_cache_.begin(); it != rule_cache_.end(); ++it) { delete it->second; } } -void MetadataLoader::Supply(const LookupKey& lookup_key, - const Callback& supplied) { +void OndemandSupplier::Supply(const LookupKey& lookup_key, + const Callback& supplied) { RuleHierarchy* hierarchy = new RuleHierarchy(lookup_key, &rule_cache_, supplied); @@ -73,28 +73,28 @@ void MetadataLoader::Supply(const LookupKey& lookup_key, hierarchy->Retrieve(*retriever_); } -MetadataLoader::RuleHierarchy::RuleHierarchy( +OndemandSupplier::RuleHierarchy::RuleHierarchy( const LookupKey& lookup_key, std::map<std::string, const Rule*>* rules, const Callback& supplied) : lookup_key_(lookup_key), rule_cache_(rules), supplied_(supplied), - retrieved_(BuildCallback(this, &MetadataLoader::RuleHierarchy::Load)), + retrieved_(BuildCallback(this, &OndemandSupplier::RuleHierarchy::Load)), success_(true) { assert(rule_cache_ != NULL); assert(retrieved_ != NULL); } -MetadataLoader::RuleHierarchy::~RuleHierarchy() { +OndemandSupplier::RuleHierarchy::~RuleHierarchy() { } -void MetadataLoader::RuleHierarchy::Queue(const std::string& key) { +void OndemandSupplier::RuleHierarchy::Queue(const std::string& key) { assert(pending_.find(key) == pending_.end()); pending_.insert(key); } -void MetadataLoader::RuleHierarchy::Retrieve(const Retriever& retriever) { +void OndemandSupplier::RuleHierarchy::Retrieve(const Retriever& retriever) { if (pending_.empty()) { Loaded(); } else { @@ -116,9 +116,9 @@ void MetadataLoader::RuleHierarchy::Retrieve(const Retriever& retriever) { } } -void MetadataLoader::RuleHierarchy::Load(bool success, - const std::string& key, - const std::string& data) { +void OndemandSupplier::RuleHierarchy::Load(bool success, + const std::string& key, + const std::string& data) { // Sanity check: This key should be present in the set of pending requests. size_t status = pending_.erase(key); assert(status == 1); // There will always be one item erased from the set. @@ -168,7 +168,7 @@ void MetadataLoader::RuleHierarchy::Load(bool success, } } -void MetadataLoader::RuleHierarchy::Loaded() { +void OndemandSupplier::RuleHierarchy::Loaded() { supplied_(success_, lookup_key_, *this); delete this; } diff --git a/cpp/src/metadata_loader.h b/cpp/src/ondemand_supplier.h index e6208a8..e8e3a7b 100644 --- a/cpp/src/metadata_loader.h +++ b/cpp/src/ondemand_supplier.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef I18N_ADDRESSINPUT_METADATA_LOADER_H_ -#define I18N_ADDRESSINPUT_METADATA_LOADER_H_ +#ifndef I18N_ADDRESSINPUT_ONDEMAND_SUPPLIER_H_ +#define I18N_ADDRESSINPUT_ONDEMAND_SUPPLIER_H_ #include <libaddressinput/callback.h> #include <libaddressinput/supplier.h> @@ -36,7 +36,7 @@ class Rule; // through which it loads address metadata as needed, creating Rule objects and // caching these. // -// When using a MetadataLoader, address validation will benefit from address +// When using an OndemandSupplier, address validation will benefit from address // metadata server synonym resolution, because the server will be contacted for // every new LookupKey (ie. every LookupKey that isn't on canonical form and // isn't already cached). @@ -44,11 +44,11 @@ class Rule; // The maximum size of this cache is naturally limited to the amount of data // available from the data server. (Currently this is less than 12,000 items of // in total less than 2 MB of JSON data.) -class MetadataLoader : public Supplier { +class OndemandSupplier : public Supplier { public: // Takes ownership of |retriever|. - MetadataLoader(const Retriever* retriever); - virtual ~MetadataLoader(); + OndemandSupplier(const Retriever* retriever); + virtual ~OndemandSupplier(); // Loads the metadata needed for |lookup_key|, then calls |supplied|. virtual void Supply(const LookupKey& lookup_key, const Callback& supplied); @@ -87,10 +87,10 @@ class MetadataLoader : public Supplier { const scoped_ptr<const Retriever> retriever_; std::map<std::string, const Rule*> rule_cache_; - DISALLOW_COPY_AND_ASSIGN(MetadataLoader); + DISALLOW_COPY_AND_ASSIGN(OndemandSupplier); }; } // namespace addressinput } // namespace i18n -#endif // I18N_ADDRESSINPUT_METADATA_LOADER_H_ +#endif // I18N_ADDRESSINPUT_ONDEMAND_SUPPLIER_H_ diff --git a/cpp/src/validation_task.h b/cpp/src/validation_task.h index 3bbc643..da0ce4b 100644 --- a/cpp/src/validation_task.h +++ b/cpp/src/validation_task.h @@ -44,7 +44,7 @@ class ValidationTask { ~ValidationTask(); - // Calls metadata->Load(), with Validate() as callback. + // Calls supplier->Load(), with Validate() as callback. void Run(Supplier* supplier) const; private: |