1 // Copyright (C) 2014 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef I18N_ADDRESSINPUT_SUPPLIER_H_
16 #define I18N_ADDRESSINPUT_SUPPLIER_H_
18 #include <libaddressinput/callback.h>
21 namespace addressinput {
26 // Interface for objects that are able to supply the AddressValidator with the
27 // metadata needed to validate an address, as described by a LookupKey.
31 typedef i18n::addressinput::Callback<const LookupKey&,
32 const RuleHierarchy&> Callback;
34 virtual ~Supplier() {}
36 // Aggregates the metadata needed for |lookup_key| into a RuleHierarchy
37 // object, then calls |supplied|. Implementations of this interface may
38 // either load the necessary data on demand, or fail if the necessary data
39 // hasn't already been loaded.
40 virtual void Supply(const LookupKey& lookup_key,
41 const Callback& supplied) = 0;
43 // A RuleHierarchy object encapsulates the hierarchical list of Rule objects
44 // that corresponds to a particular LookupKey.
45 struct RuleHierarchy {
46 RuleHierarchy() : rule() {}
47 const Rule* rule[4]; // Cf. LookupKey::kHierarchy.
51 } // namespace addressinput
54 #endif // I18N_ADDRESSINPUT_SUPPLIER_H_