MythTV  master
videometadatalistmanager.h
Go to the documentation of this file.
1 #ifndef VIDEOMETADATALISTMANAGER_H_
2 #define VIDEOMETADATALISTMANAGER_H_
3 
4 #include <list>
5 
6 #include "quicksp.h"
7 #include "videometadata.h"
8 #include "mythmetaexp.h"
9 
11 {
12  public:
14  using metadata_list = std::list<VideoMetadataPtr>;
15 
16  public:
17  static VideoMetadataPtr loadOneFromDatabase(uint id);
18  static void loadAllFromDatabase(metadata_list &items,
19  const QString &sql = "");
20 
21  public:
24 
25  void setList(metadata_list &list);
26  const metadata_list &getList() const;
27 
28  VideoMetadataPtr byFilename(const QString &file_name) const;
29  VideoMetadataPtr byID(unsigned int db_id) const;
30 
31  bool purgeByFilename(const QString &file_name);
32  bool purgeByID(unsigned int db_id);
33 
34  private:
35  class VideoMetadataListManagerImp *m_imp {nullptr};
36 };
37 
39 {
40  public:
41  meta_node(meta_node *parent, bool is_path_root = false) :
42  m_parent(parent), m_pathRoot(is_path_root) {}
43  virtual ~meta_node() = default;
44 
45  virtual const QString &getName() const = 0;
46  virtual const QString &getPath() const;
47  const QString &getFQPath();
48  void setParent(meta_node *parent);
49  void setPathRoot(bool is_root = true);
50 
51  protected:
52  meta_node *m_parent {nullptr};
53 
54  private:
55  QString m_fqPath;
56  bool m_pathRoot;
57  static const QString kEmptyPath;
58 };
59 
61 {
62  public:
63  meta_data_node(VideoMetadata *data, meta_node *parent = nullptr) :
64  meta_node(parent), m_data(data) {}
65  const QString &getName() const override; // meta_node
66  const VideoMetadata *getData() const;
67  VideoMetadata *getData();
68 
69  private:
70  VideoMetadata *m_data {nullptr};
71  static const QString kMetaBug;
72 };
73 
74 class meta_dir_node;
75 
78 
79 using meta_dir_list = std::list<smart_dir_node>;
80 using meta_data_list = std::list<smart_meta_node>;
81 
83 {
84  public:
85  using dir_iterator = meta_dir_list::iterator;
86  using const_dir_iterator = meta_dir_list::const_iterator;
87 
88  using entry_iterator = meta_data_list::iterator;
89  using const_entry_iterator = meta_data_list::const_iterator;
90 
91  public:
92  meta_dir_node(const QString &path, const QString &name = "",
93  meta_dir_node *parent = nullptr, bool is_path_root = false,
94  QString host = "", QString prefix = "",
95  QVariant data = QVariant());
96  meta_dir_node() : meta_node(nullptr) { }
97 
98  void ensureSortFields();
99  void setName(const QString &name);
100  const QString &getName() const override; // meta_node
101  void SetHost(const QString &host);
102  const QString &GetHost() const;
103  void SetPrefix(const QString &prefix);
104  const QString &GetPrefix() const;
105  const QString &getPath() const override; // meta_node
106  const QString &getSortPath() const;
107  void setPath(const QString &path, const QString &sortPath = nullptr);
108  void SetData(const QVariant &data);
109  const QVariant &GetData() const;
110  bool DataIsValid(void) const;
111  smart_dir_node addSubDir(const QString &subdir,
112  const QString &name = "",
113  const QString &host = "",
114  const QString &prefix = "",
115  const QVariant &data = QVariant());
116  void addSubDir(const smart_dir_node &subdir);
117  smart_dir_node getSubDir(const QString &subdir,
118  const QString &name = "",
119  bool create = true,
120  const QString &host = "",
121  const QString &prefix = "",
122  const QVariant &data = QVariant());
123  void addEntry(const smart_meta_node &entry);
124  void clear();
125  bool empty() const;
126  int subdir_count() const;
127  template <typename DirSort, typename EntrySort>
128  void sort(DirSort dir_sort, EntrySort entry_sort)
129  {
130  m_subdirs.sort(dir_sort);
131  m_entries.sort(entry_sort);
132 
133  for (auto & subdir : m_subdirs)
134  {
135  subdir->sort(dir_sort, entry_sort);
136  }
137  }
138  dir_iterator dirs_begin();
139  dir_iterator dirs_end();
140  const_dir_iterator dirs_begin() const;
141  const_dir_iterator dirs_end() const;
142  entry_iterator entries_begin();
143  entry_iterator entries_end();
144  const_entry_iterator entries_begin() const;
145  const_entry_iterator entries_end() const;
146  bool has_entries() const;
147 
148  private:
149  QString m_path;
150  QString m_sortPath;
151  QString m_name;
152  QString m_host;
153  QString m_prefix;
156 
157  QVariant m_data;
158 };
159 #endif // VIDEOMETADATALISTMANAGER_H_
meta_node
Definition: videometadatalistmanager.h:38
VideoMetadata
Definition: videometadata.h:24
meta_dir_node::m_name
QString m_name
Definition: videometadatalistmanager.h:151
meta_dir_node::meta_dir_node
meta_dir_node()
Definition: videometadatalistmanager.h:96
meta_dir_node::m_sortPath
QString m_sortPath
Definition: videometadatalistmanager.h:150
meta_dir_node::const_dir_iterator
meta_dir_list::const_iterator const_dir_iterator
Definition: videometadatalistmanager.h:86
videometadata.h
meta_dir_node::m_host
QString m_host
Definition: videometadatalistmanager.h:152
VideoMetadataListManager
Definition: videometadatalistmanager.h:10
meta_dir_node::const_entry_iterator
meta_data_list::const_iterator const_entry_iterator
Definition: videometadatalistmanager.h:89
meta_dir_node::sort
void sort(DirSort dir_sort, EntrySort entry_sort)
Definition: videometadatalistmanager.h:128
simple_ref_ptr
Definition: quicksp.h:24
meta_dir_node::m_subdirs
meta_dir_list m_subdirs
Definition: videometadatalistmanager.h:154
meta_node::kEmptyPath
static const QString kEmptyPath
Definition: videometadatalistmanager.h:57
meta_dir_node::entry_iterator
meta_data_list::iterator entry_iterator
Definition: videometadatalistmanager.h:88
meta_dir_node
Definition: videometadatalistmanager.h:82
meta_node::meta_node
meta_node(meta_node *parent, bool is_path_root=false)
Definition: videometadatalistmanager.h:41
meta_dir_node::dir_iterator
meta_dir_list::iterator dir_iterator
Definition: videometadatalistmanager.h:85
meta_dir_node::m_entries
meta_data_list m_entries
Definition: videometadatalistmanager.h:155
meta_data_node::meta_data_node
meta_data_node(VideoMetadata *data, meta_node *parent=nullptr)
Definition: videometadatalistmanager.h:63
mythmetaexp.h
meta_node::getName
virtual const QString & getName() const =0
hardwareprofile.distros.mythtv_data.data_mythtv.prefix
string prefix
Definition: data_mythtv.py:40
meta_data_node::kMetaBug
static const QString kMetaBug
Definition: videometadatalistmanager.h:71
meta_dir_node::m_prefix
QString m_prefix
Definition: videometadatalistmanager.h:153
clear
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:846
meta_node::m_pathRoot
bool m_pathRoot
Definition: videometadatalistmanager.h:56
meta_dir_node::m_data
QVariant m_data
Definition: videometadatalistmanager.h:157
uint
unsigned int uint
Definition: compat.h:140
meta_data_node
Definition: videometadatalistmanager.h:60
meta_node::getPath
virtual const QString & getPath() const
Definition: videometadatalistmanager.cpp:194
meta_dir_node::m_path
QString m_path
Definition: videometadatalistmanager.h:149
VideoMetadataListManagerImp
Definition: videometadatalistmanager.cpp:7
meta_node::m_fqPath
QString m_fqPath
Definition: videometadatalistmanager.h:55
meta_dir_list
std::list< smart_dir_node > meta_dir_list
Definition: videometadatalistmanager.h:79
VideoMetadataListManager::metadata_list
std::list< VideoMetadataPtr > metadata_list
Definition: videometadatalistmanager.h:14
quicksp.h
meta_data_list
std::list< smart_meta_node > meta_data_list
Definition: videometadatalistmanager.h:80
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9