reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

package.hpp (2591B)


      1 /* ReaPack: Package manager for REAPER
      2  * Copyright (C) 2015-2025  Christian Fillion
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU Lesser General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU Lesser General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Lesser General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 #ifndef REAPACK_PACKAGE_HPP
     19 #define REAPACK_PACKAGE_HPP
     20 
     21 #include "metadata.hpp"
     22 #include "version.hpp"
     23 
     24 class Category;
     25 
     26 class Package {
     27 public:
     28   enum Type {
     29     UnknownType,
     30     ScriptType,
     31     ExtensionType,
     32     EffectType,
     33     DataType,
     34     ThemeType,
     35     LangPackType,
     36     WebInterfaceType,
     37     ProjectTemplateType,
     38     TrackTemplateType,
     39     MIDINoteNamesType,
     40     AutomationItemType,
     41   };
     42 
     43   static Type getType(const char *);
     44   static const char *displayType(Type);
     45   static const std::string &displayName(const std::string &name, const std::string &desc);
     46 
     47   Package(const Type, const std::string &name, const Category *);
     48   ~Package();
     49 
     50   const Category *category() const { return m_category; }
     51   Type type() const { return m_type; }
     52   std::string displayType() const { return displayType(m_type); }
     53   const std::string &name() const { return m_name; }
     54   std::string fullName() const;
     55   void setDescription(const std::string &d) { m_desc = d; }
     56   const std::string &description() const { return m_desc; }
     57   const std::string &displayName() const
     58     { return displayName(m_name, m_desc); }
     59 
     60   Metadata *metadata() { return &m_metadata; }
     61   const Metadata *metadata() const { return &m_metadata; }
     62 
     63   bool addVersion(const Version *ver);
     64   const auto &versions() const { return m_versions; }
     65   const Version *version(size_t index) const;
     66   const Version *lastVersion(bool pres = true, const VersionName &from = {}) const;
     67   const Version *findVersion(const VersionName &) const;
     68 
     69 private:
     70   class CompareVersion {
     71   public:
     72     bool operator()(const Version *l, const Version *r) const
     73     {
     74       return l->name() < r->name();
     75     }
     76   };
     77 
     78   const Category *m_category;
     79 
     80   Type m_type;
     81   std::string m_name;
     82   std::string m_desc;
     83   Metadata m_metadata;
     84   std::set<const Version *, CompareVersion> m_versions;
     85 
     86 };
     87 
     88 #endif