diff options
Diffstat (limited to 'mythfs/service/inodes')
-rw-r--r-- | mythfs/service/inodes/byTitleDirectory.cpp | 22 | ||||
-rw-r--r-- | mythfs/service/inodes/byTitleDirectory.h | 5 | ||||
-rw-r--r-- | mythfs/service/inodes/groupingDirectory.cpp | 24 | ||||
-rw-r--r-- | mythfs/service/inodes/groupingDirectory.h | 6 |
4 files changed, 56 insertions, 1 deletions
diff --git a/mythfs/service/inodes/byTitleDirectory.cpp b/mythfs/service/inodes/byTitleDirectory.cpp new file mode 100644 index 0000000..148f441 --- /dev/null +++ b/mythfs/service/inodes/byTitleDirectory.cpp @@ -0,0 +1,22 @@ +#include "byTitleDirectory.h" +#include "symlink.h" + +namespace MythFS { + ByTitleDirectory::ByTitleDirectory(DBPrx db) : + GroupingDirectory<std::string>(db) + { + } + + std::string + ByTitleDirectory::attribute(const MythFS::RecordedPtr & r) const + { + return r->title; + } + + Node::PointerType + ByTitleDirectory::getChild(const std::string & ) const + { + return new Symlink("/"); + } +} + diff --git a/mythfs/service/inodes/byTitleDirectory.h b/mythfs/service/inodes/byTitleDirectory.h index e9883d1..2d88b80 100644 --- a/mythfs/service/inodes/byTitleDirectory.h +++ b/mythfs/service/inodes/byTitleDirectory.h @@ -5,9 +5,12 @@ namespace MythFS { class ByTitleDirectory : public GroupingDirectory<std::string> { + public: + ByTitleDirectory(DBPrx db); protected: - virtual std::string attribute(const MythFS::RecordedPtr &) const; + std::string attribute(const MythFS::RecordedPtr &) const override; + PointerType getChild(const std::string &) const override; }; } diff --git a/mythfs/service/inodes/groupingDirectory.cpp b/mythfs/service/inodes/groupingDirectory.cpp new file mode 100644 index 0000000..30e71d8 --- /dev/null +++ b/mythfs/service/inodes/groupingDirectory.cpp @@ -0,0 +1,24 @@ +#include "groupingDirectory.h" +#include <algorithm> + +namespace MythFS { + template<typename T> + GroupingDirectory<T>::GroupingDirectory(DBPrx d) : db(d) { } + + template<typename T> + NetFS::NameList + GroupingDirectory<T>::getContents() const + { + NetFS::NameList values; + for (auto r : db->getRecorded()) { + auto a = attribute(r); + if (std::find(values.begin(), values.end(), a) == values.end()) { + values.push_back(a); + } + } + return values; + } + + template class GroupingDirectory<std::string>; +} + diff --git a/mythfs/service/inodes/groupingDirectory.h b/mythfs/service/inodes/groupingDirectory.h index 82b3c0c..5e587ac 100644 --- a/mythfs/service/inodes/groupingDirectory.h +++ b/mythfs/service/inodes/groupingDirectory.h @@ -2,14 +2,20 @@ #define MYTHFS_GROUPINGDIRECTORY_H #include "abstractDynamicDirectory.h" +#include <myth-models.h> +#include <myth-db.h> namespace MythFS { template <typename T> class GroupingDirectory : public AbstractDynamicDirectory { public: + GroupingDirectory(DBPrx db); + protected: virtual T attribute(const MythFS::RecordedPtr &) const = 0; NetFS::NameList getContents() const override; + + DBPrx db; }; } |