Browse Source

[1975] Rename search -> find

To have better naming consistency.
Michal 'vorner' Vaner 13 years ago
parent
commit
eb9d328b4b
3 changed files with 55 additions and 55 deletions
  1. 7 7
      src/lib/datasrc/container.cc
  2. 22 22
      src/lib/datasrc/container.h
  3. 26 26
      src/lib/datasrc/tests/container_unittest.cc

+ 7 - 7
src/lib/datasrc/container.cc

@@ -64,13 +64,13 @@ ConfigurableContainer::configure(const Element& config, bool) {
     }
 }
 
-Container::SearchResult
-ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
-                              bool) const
+Container::FindResult
+ConfigurableContainer::find(const dns::Name& name, bool want_exact_match,
+                            bool) const
 {
     // Nothing found yet.
-    // Pointer is used as the SearchResult can't be assigned.
-    auto_ptr<SearchResult> candidate(new SearchResult());
+    // Pointer is used as the FindResult can't be assigned.
+    auto_ptr<FindResult> candidate(new FindResult());
 
     BOOST_FOREACH(const DataSourceInfo& info, data_sources_) {
         // TODO: Once we have support for the caches, consider them too here
@@ -88,7 +88,7 @@ ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
 
                 // TODO: In case we have only the datasource and not the finder
                 // and the need_updater parameter is true, get the zone there.
-                return (SearchResult(info.data_src_, result.zone_finder,
+                return (FindResult(info.data_src_, result.zone_finder,
                                      name.getLabelCount(), true));
             }
             case result::PARTIALMATCH: {
@@ -99,7 +99,7 @@ ConfigurableContainer::search(const dns::Name& name, bool want_exact_match,
                         result.zone_finder->getOrigin().getLabelCount());
                     if (labels > candidate->matched_labels_) {
                         // This one is strictly better. Replace it.
-                        candidate.reset(new SearchResult(info.data_src_,
+                        candidate.reset(new FindResult(info.data_src_,
                                                          result.zone_finder,
                                                          labels, false));
                     }

+ 22 - 22
src/lib/datasrc/container.h

@@ -55,19 +55,19 @@ protected:
     /// class.
     Container() {}
 public:
-    /// \brief Structure holding the (compound) result of search.
+    /// \brief Structure holding the (compound) result of find.
     ///
     /// As this is read-only structure, we don't bother to create accessors.
     /// Instead, all the member variables are defined as const and can be
     /// accessed directly.
-    struct SearchResult {
+    struct FindResult {
         /// \brief Constructor.
         ///
         /// It simply fills in the member variables according to the
         /// parameters. See the member descriptions for their meaning.
-        SearchResult(DataSourceClient* datasrc,
-                     const ZoneFinderPtr& finder,
-                     uint8_t matched_labels, bool exact_match) :
+        FindResult(DataSourceClient* datasrc,
+                   const ZoneFinderPtr& finder,
+                   uint8_t matched_labels, bool exact_match) :
             datasrc_(datasrc),
             finder_(finder),
             matched_labels_(matched_labels),
@@ -78,7 +78,7 @@ public:
         ///
         /// This conscructs a result for negative answer. Both pointers are
         /// NULL, matched_labels_ is 0 and exact_match_ is false.
-        SearchResult() :
+        FindResult() :
             datasrc_(NULL),
             matched_labels_(0),
             exact_match_(false)
@@ -88,7 +88,7 @@ public:
         ///
         /// It is needed for tests and it might be of some use elsewhere
         /// too.
-        bool operator ==(const SearchResult& other) const {
+        bool operator ==(const FindResult& other) const {
             return (datasrc_ == other.datasrc_ &&
                     finder_ == other.finder_ &&
                     matched_labels_ == other.matched_labels_ &&
@@ -105,9 +105,9 @@ public:
         ///
         /// This is the finder corresponding to the best matching zone.
         /// This may be NULL even in case the datasrc_ is something
-        /// else, depending on the search options.
+        /// else, depending on the find options.
         ///
-        /// \see search
+        /// \see find
         const ZoneFinderPtr finder_;
 
         /// \brief Number of matching labels.
@@ -129,7 +129,7 @@ public:
     /// this case, the zone finder is needed and the best matching superzone
     /// of the searched name is needed. Therefore, the call would look like:
     ///
-    ///   SearchResult result(container->search(queried_name));
+    ///   FindResult result(container->find(queried_name));
     ///   if (result.datasrc_) {
     ///       createTheAnswer(result.finder_);
     ///   } else {
@@ -141,20 +141,20 @@ public:
     /// we need an exact match (if we want to manipulate zone data, we must
     /// know exactly, which zone we are about to manipulate). Then the call
     ///
-    ///   SearchResult result(container->search(zone_name, true, false));
+    ///   FindResult result(container->find(zone_name, true, false));
     ///   if (result.datasrc_) {
     ///       ZoneUpdaterPtr updater(result.datasrc_->getUpdater(zone_name);
     ///       ...
     ///   }
     ///
-    /// \param zone The name of the zone to search.
+    /// \param zone The name of the zone to look for.
     /// \param want_exact_match If it is true, it returns only exact matches.
     ///     If the best possible match is partial, a negative result is
     ///     returned instead. It is possible the caller could check it and
     ///     act accordingly if the result would be partial match, but with this
-    ///     set to true, the search might be actually faster under some
+    ///     set to true, the find might be actually faster under some
     ///     circumstances.
-    /// \param want_finder If this is false, the finder_ member of SearchResult
+    /// \param want_finder If this is false, the finder_ member of FindResult
     ///     might be NULL even if the corresponding data source is found. This
     ///     is because of performance, in some cases the finder is a side
     ///     result of the searching algorithm (therefore asking for it again
@@ -164,11 +164,11 @@ public:
     ///     Other things are never the side effect of searching, therefore the
     ///     caller can get them explicitly (the updater, journal reader and
     ///     iterator).
-    /// \return A SearchResult describing the data source and zone with the
+    /// \return A FindResult describing the data source and zone with the
     ///     longest match against the zone parameter.
-    virtual SearchResult search(const dns::Name& zone,
-                                bool want_exact_match = false,
-                                bool want_finder = true) const = 0;
+    virtual FindResult find(const dns::Name& zone,
+                            bool want_exact_match = false,
+                            bool want_finder = true) const = 0;
 };
 
 /// \brief Shared pointer to the container.
@@ -215,10 +215,10 @@ public:
     ///     sense.
     void configure(const data::Element& configuration, bool allow_cache);
 
-    /// \brief Implementation of the Container::search.
-    virtual SearchResult search(const dns::Name& zone,
-                                bool want_exact_match = false,
-                                bool want_finder = true) const;
+    /// \brief Implementation of the Container::find.
+    virtual FindResult find(const dns::Name& zone,
+                              bool want_exact_match = false,
+                              bool want_finder = true) const;
 
     /// \brief This holds one data source and corresponding information.
     ///

+ 26 - 26
src/lib/datasrc/tests/container_unittest.cc

@@ -175,7 +175,7 @@ public:
         }
     }
     // Check the positive result is as we expect it.
-    void positiveResult(const Container::SearchResult& result,
+    void positiveResult(const Container::FindResult& result,
                         const shared_ptr<TestDS>& dsrc,
                         const Name& name, bool exact,
                         const char* test)
@@ -227,7 +227,7 @@ public:
         EXPECT_TRUE(Element::fromJSON(params)->equals(*ds->configuration_));
     }
     shared_ptr<TestedContainer> container_;
-    const Container::SearchResult negativeResult_;
+    const Container::FindResult negativeResult_;
     vector<shared_ptr<TestDS> > ds_;
     vector<ConfigurableContainer::DataSourceInfo> ds_info_;
     const ConstElementPtr config_elem_;
@@ -247,7 +247,7 @@ TEST_F(ContainerTest, emptyContainer) {
     EXPECT_TRUE(container_->dataSources().empty());
 }
 
-// Check the values returned by a search on an empty container. It should be
+// Check the values returned by a find on an empty container. It should be
 // a negative answer (nothing found) no matter if we want an exact or inexact
 // match.
 TEST_F(ContainerTest, emptySearch) {
@@ -255,14 +255,14 @@ TEST_F(ContainerTest, emptySearch) {
 
     // Note: we don't have operator<< for the result class, so we cannot use
     // EXPECT_EQ.  Same for other similar cases.
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"),
-                                                      false, false));
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"),
-                                                      false, true));
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"), true,
-                                                      false));
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("example.org"), true,
-                                                      true));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("example.org"),
+                                                    false, false));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("example.org"),
+                                                    false, true));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("example.org"), true,
+                                                    false));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("example.org"), true,
+                                                    true));
 }
 
 // Put a single data source inside the container and check it can find an
@@ -270,27 +270,27 @@ TEST_F(ContainerTest, emptySearch) {
 TEST_F(ContainerTest, singleDSExactMatch) {
     container_->dataSources().push_back(ds_info_[0]);
     // This zone is not there
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("org."), true));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("org."), true));
     // But this one is, so check it.
-    positiveResult(container_->search(Name("example.org"), true),
+    positiveResult(container_->find(Name("example.org"), true),
                    ds_[0], Name("example.org"), true, "Exact match");
     // When asking for a sub zone of a zone there, we get nothing
     // (we want exact match, this would be partial one)
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("sub.example.org."),
-                                                      true));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("sub.example.org."),
+                                                    true));
 }
 
 // When asking for a partial match, we get all that the exact one, but more.
 TEST_F(ContainerTest, singleDSBestMatch) {
     container_->dataSources().push_back(ds_info_[0]);
     // This zone is not there
-    EXPECT_TRUE(negativeResult_ == container_->search(Name("org.")));
+    EXPECT_TRUE(negativeResult_ == container_->find(Name("org.")));
     // But this one is, so check it.
-    positiveResult(container_->search(Name("example.org")),
+    positiveResult(container_->find(Name("example.org")),
                    ds_[0], Name("example.org"), true, "Exact match");
     // When asking for a sub zone of a zone there, we get nothing
     // (we want exact match, this would be partial one)
-    positiveResult(container_->search(Name("sub.example.org.")),
+    positiveResult(container_->find(Name("sub.example.org.")),
                    ds_[0], Name("example.org"), false, "Subdomain match");
 }
 
@@ -307,17 +307,17 @@ TEST_F(ContainerTest, multiExactMatch) {
         SCOPED_TRACE(test_names[i]);
         multiConfiguration(i);
         // Something that is nowhere there
-        EXPECT_TRUE(negativeResult_ == container_->search(Name("org."), true));
+        EXPECT_TRUE(negativeResult_ == container_->find(Name("org."), true));
         // This one is there exactly.
-        positiveResult(container_->search(Name("example.org"), true),
+        positiveResult(container_->find(Name("example.org"), true),
                        ds_[0], Name("example.org"), true, "Exact match");
         // This one too, but in a different data source.
-        positiveResult(container_->search(Name("sub.example.org."), true),
+        positiveResult(container_->find(Name("sub.example.org."), true),
                        ds_[1], Name("sub.example.org"), true,
                        "Subdomain match");
         // But this one is in neither data source.
         EXPECT_TRUE(negativeResult_ ==
-                    container_->search(Name("sub.example.com."), true));
+                    container_->find(Name("sub.example.com."), true));
     }
 }
 
@@ -327,17 +327,17 @@ TEST_F(ContainerTest, multiBestMatch) {
         SCOPED_TRACE(test_names[i]);
         multiConfiguration(i);
         // Something that is nowhere there
-        EXPECT_TRUE(negativeResult_ == container_->search(Name("org.")));
+        EXPECT_TRUE(negativeResult_ == container_->find(Name("org.")));
         // This one is there exactly.
-        positiveResult(container_->search(Name("example.org")),
+        positiveResult(container_->find(Name("example.org")),
                        ds_[0], Name("example.org"), true, "Exact match");
         // This one too, but in a different data source.
-        positiveResult(container_->search(Name("sub.example.org.")),
+        positiveResult(container_->find(Name("sub.example.org.")),
                        ds_[1], Name("sub.example.org"), true,
                        "Subdomain match");
         // But this one is in neither data source. But it is a subdomain
         // of one of the zones in the first data source.
-        positiveResult(container_->search(Name("sub.example.com.")),
+        positiveResult(container_->find(Name("sub.example.com.")),
                        ds_[0], Name("example.com."), false,
                        "Subdomain in com");
     }