File indexing completed on 2025-01-19 03:53:04

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-03-20
0007  * Description : a tool to export images to iNaturalist web service
0008  *
0009  * SPDX-FileCopyrightText: 2021      by Joerg Lohse <joergmlpts at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_INAT_TAXON_H
0016 #define DIGIKAM_INAT_TAXON_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 #include <QUrl>
0022 #include <QList>
0023 
0024 namespace DigikamGenericINatPlugin
0025 {
0026 
0027 /**
0028  * A taxon is obtained via the iNaturalist API and it is read-only; thus there
0029  * are no member functions to modify it and only const-references to its members
0030  * are returned.
0031  *
0032  * Taxa have a unique numeric id and a name - the scientific or Latin name.
0033  * Taxa also have a textual rank (e.g. 'species') and a numeric rank-level (10
0034  * for species).
0035  * The common name may not be present and its value depends on the locale: it
0036  * can be Chien, Gedomesticeerde Hond, Домашняя Собака, Domestic Dog, Haushund,
0037  * or Perro Doméstico for the iNaturalist taxon with id 47144 and scientific
0038  * name 'Canis familiaris'. Even in the same country and language common names
0039  * differ from place to place. E.g. 'Umbellularia californica' is the scientific
0040  * name of a tree in the laurel family that occurs in California and Oregon. Its
0041  * common name is 'California Bay Laurel' in California and 'Oregon Myrtle' in
0042  * Oregon.
0043  * Member 'ancestors' is a list of parent taxa ordered from the highest
0044  * rank 'kingdom' downwards. The url fetches a small, square-shape icon and is
0045  * unavailable for some taxa. The matched term is only non-empty for taxa
0046  * returned from auto-completion.
0047  */
0048 class Taxon
0049 {
0050 public:
0051 
0052     Taxon(int id,
0053           int parentId,
0054           const QString& name,
0055           const QString& rank,
0056           double rankLevel,
0057           const QString& commonName,
0058           const QString& matchedTerm,
0059           const QUrl& squareUrl,
0060           const QList<Taxon>& ancestors);
0061     Taxon();
0062     Taxon(const Taxon&);
0063     ~Taxon();
0064 
0065     bool                isValid()     const;
0066     int                 id()          const;
0067     int                 parentId()    const;
0068     const QString&      name()        const;
0069     QString             htmlName()    const;
0070     const QString&      rank()        const;
0071     double              rankLevel()   const;
0072     const QString&      commonName()  const;
0073     const QList<Taxon>& ancestors()   const;
0074     const QUrl&         squareUrl()   const;
0075     const QString&      matchedTerm() const;
0076 
0077     Taxon& operator= (const Taxon&);
0078     bool   operator!=(const Taxon&)   const;
0079     bool   operator==(const Taxon&)   const;
0080 
0081 private:
0082 
0083     class Private;
0084     Private* const d;
0085 };
0086 
0087 } // namespace DigikamGenericINatPlugin
0088 
0089 #endif // DIGIKAM_INAT_TAXON_H