bpp-popgen3  3.0.0
Locality.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef _LOCALITY_H_
6 #define _LOCALITY_H_
7 
8 // From std lib
9 #include <string>
10 
11 #include <Bpp/Graphics/Point2D.h>
12 
13 namespace bpp
14 {
23 template<class T> class Locality :
24  public bpp::Point2D<T>
25 {
26 protected:
27  std::string name_;
28 
29 public:
30  // Constructors and destructor
38  Locality<T>(const std::string name, const T x = 0, const T y = 0) :
39  bpp::Point2D<T>(x, y),
40  name_(name) {}
41 
48  Locality<T>(const std::string name, const bpp::Point2D<T>& coord) :
49  bpp::Point2D<T>(coord),
50  name_(name) {}
51 
55  virtual ~Locality<T>() {}
56 
57 public:
58  // Methodes
62  Locality<T>* clone() const { return new Locality<T>(*this); }
63 
69  virtual bool operator==(const Locality<T>& locality) const
70  {
71  return this->getX() == locality.getX() && this->getY() == locality.getY() && name_ == locality.name_;
72  }
73 
77  virtual bool operator!=(const Locality<T>& locality) const
78  {
79  return !(locality == *this);
80  }
81 
85  void setName(const std::string& name) { name_ = name; }
86 
90  const std::string& getName() const { return name_; }
91 };
92 } // end of namespace bpp;
93 
94 #endif // _LOCALITY_H_
The Locality class.
Definition: Locality.h:25
virtual bool operator!=(const Locality< T > &locality) const
The != operator.
Definition: Locality.h:77
const std::string & getName() const
Get the name of the locality.
Definition: Locality.h:90
virtual bool operator==(const Locality< T > &locality) const
The == operator.
Definition: Locality.h:69
void setName(const std::string &name)
Set the name of the locality.
Definition: Locality.h:85
std::string name_
Definition: Locality.h:27
Locality< T > * clone() const
Implements the Clonable interface.
Definition: Locality.h:62
const T & getY() const
const T & getX() const