MetricKnn API
Fast Similarity Search using the Metric Space Approach
mknn_distance.hpp
1 /*
2  * Copyright (C) 2012-2015, Juan Manuel Barrios <juanmanuel@barrios.cl>
3  * All rights reserved.
4  *
5  * This file is part of MetricKnn.
6  * MetricKnn is made available under the terms of the BSD 2-Clause License.
7  */
8 
9 #ifndef MKNN_DISTANCE_HPP_
10 #define MKNN_DISTANCE_HPP_
11 
12 #include "../metricknn_cpp.hpp"
13 
14 namespace mknn {
15 
16 class DistanceEval;
17 class DistanceCustomFactory;
18 
59 class Distance {
60 public:
70  static Distance newPredefined(DistanceParams &parameters);
71 
84  bool delete_factory_on_distance_release);
85 
91 
96  std::string getIdPredefinedDistance();
97 
109  DistanceEval newDistanceEval(Domain domain_left, Domain domain_right);
110 
125  void save(std::string filename_write);
126 
137  static Distance restore(std::string filename_read,
138  DistanceParams &more_parameters);
139 
147  Distance();
151  virtual ~Distance();
155  Distance(const Distance &other);
159  Distance &operator=(const Distance &other);
160 
161 protected:
165  class Impl;
169  std::unique_ptr<Impl> pimpl;
170 
171  friend class Domain;
172  friend class Index;
173 };
174 
179 public:
192  virtual double evalDistance(void *object_left, void *object_right,
193  double current_threshold) = 0;
194 
195  virtual ~DistanceCustomInstance() = 0;
196 };
197 
202 public:
213  virtual DistanceCustomInstance *newInstance(Domain *domain_left,
214  Domain *domain_right) = 0;
215 
216  virtual ~DistanceCustomFactory() = 0;
217 
218 };
219 
220 }
221 
222 #endif
Stores parameters in an internal map, which associates a names with its value.
Definition: mknn_params.hpp:21
Abstract class that must be inherited to define a custom distance.
Definition: mknn_distance.hpp:178
Abstract class that must be inherited to define a custom distance.
Definition: mknn_distance.hpp:201
Distance & operator=(const Distance &other)
Assignment operator.
virtual ~Distance()
Default destructor.
DistanceEval newDistanceEval(Domain domain_left, Domain domain_right)
Creates a distance for computing distances between objects of the given domains.
virtual double evalDistance(void *object_left, void *object_right, double current_threshold)=0
The function of a custom distance that computes the distance between two objects. ...
A Index represents the index structure.
Definition: mknn_index.hpp:45
void save(std::string filename_write)
The distance is saved to a file.
static Distance restore(std::string filename_read, DistanceParams &more_parameters)
Loads a distance from a file.
This class computes the distance between two objects from a given Domain.
Definition: mknn_distance_eval.hpp:19
Definition: mevaluation_answers.hpp:18
Distance()
Default constructor.
DistanceParams & getParameters()
Return the parameters used to create the distance.
static Distance newCustom(DistanceCustomFactory *factory, bool delete_factory_on_distance_release)
Creates a new custom function.
The Distance is the object with the definition of the method for comparing objects.
Definition: mknn_distance.hpp:59
virtual DistanceCustomInstance * newInstance(Domain *domain_left, Domain *domain_right)=0
The function of a custom distance that creates a new state.
A domain represents the type of object that are contained in a dataset.
Definition: mknn_domain.hpp:33
std::string getIdPredefinedDistance()
The id of the predefined distance.
static Distance newPredefined(DistanceParams &parameters)
Creates a new distance for the given parameters.
std::unique_ptr< Impl > pimpl
Internal opaque class.
Definition: mknn_distance.hpp:165
Powered by Download MetricKnn