]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/collection.cpp
Redesign automatic object loading
[libs/datafile.git] / source / collection.cpp
index d52ee22399ba7500c880798f2fcf3036d9cd095c..bf1c5edc211e93b33f1dacc833e0ac1a38657a5e 100644 (file)
@@ -1,5 +1,7 @@
 #include "collection.h"
 
+using namespace std;
+
 namespace Msp {
 namespace DataFile {
 
@@ -9,6 +11,11 @@ Collection::~Collection()
                delete *i;
 }
 
+void Collection::add_source(CollectionSource &s)
+{
+       sources.push_back(&s);
+}
+
 
 Collection::Loader::Loader(Collection &c):
        coll(c)
@@ -27,5 +34,25 @@ CollectionItemTypeBase::~CollectionItemTypeBase()
        delete tag;
 }
 
+void CollectionItemTypeBase::set_keyword(const string &k)
+{
+       kwd = k;
+       if(suffixes.empty())
+               add_suffix("."+kwd);
+}
+
+void CollectionItemTypeBase::add_suffix(const string &s)
+{
+       suffixes.push_back(s);
+}
+
+bool CollectionItemTypeBase::match_name(const string &name) const
+{
+       for(vector<string>::const_iterator i=suffixes.begin(); i!=suffixes.end(); ++i)
+               if(name.size()>i->size() && !name.compare(name.size()-i->size(), string::npos, *i))
+                       return true;
+       return false;
+}
+
 } // namespace DataFile
 } // namespace Msp