summaryrefslogtreecommitdiff
path: root/src/package.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-01-10 14:13:43 +0000
committerCarl Hetherington <cth@carlh.net>2016-01-10 14:13:43 +0000
commit0ffc4c35a9ae232f3bed9329997c043c42372f6f (patch)
tree9d1373403362572518600e163e7caad2f63b67a4 /src/package.h
parent93f29880839dc5589bb35f63260a7152ead7655f (diff)
Template Package and bring some stuff up to there and PackageBase.
Diffstat (limited to 'src/package.h')
-rw-r--r--src/package.h51
1 files changed, 37 insertions, 14 deletions
diff --git a/src/package.h b/src/package.h
index b3d3b4ed..ac33ac9f 100644
--- a/src/package.h
+++ b/src/package.h
@@ -20,29 +20,52 @@
#ifndef LIBDCP_PACKAGE_H
#define LIBDCP_PACKAGE_H
-#include "exceptions.h"
-#include <boost/filesystem.hpp>
+#include "package_base.h"
+#include "dc_cpl.h"
+#include <boost/foreach.hpp>
namespace dcp {
class Asset;
-class Package
+template <class T>
+class Package : public PackageBase
{
public:
- Package (boost::filesystem::path directory);
-
- typedef std::list<boost::shared_ptr<PackageReadError> > ReadErrors;
+ Package (boost::filesystem::path directory)
+ : PackageBase (directory)
+ {
+
+ }
+
+ void read (bool keep_going = false, ReadErrors* errors = 0)
+ {
+ std::list<boost::shared_ptr<dcp::Asset> > other_assets;
+
+ BOOST_FOREACH (boost::shared_ptr<dcp::Asset> i, read_assetmap (keep_going, errors)) {
+ boost::shared_ptr<T> cpl = boost::dynamic_pointer_cast<T> (i);
+ if (cpl) {
+ _cpls.push_back (cpl);
+ } else {
+ other_assets.push_back (i);
+ }
+ }
+
+ BOOST_FOREACH (boost::shared_ptr<T> i, _cpls) {
+ i->resolve_refs (other_assets);
+ }
+ }
+
+ void resolve_refs (std::list<boost::shared_ptr<dcp::Asset> > assets)
+ {
+ BOOST_FOREACH (boost::shared_ptr<T> i, _cpls) {
+ i->resolve_refs (assets);
+ }
+ }
protected:
-
- virtual boost::shared_ptr<Asset> xml_asset_factory (boost::filesystem::path file, std::string root) const = 0;
- virtual boost::shared_ptr<Asset> mxf_asset_factory (boost::filesystem::path file) const = 0;
-
- std::list<boost::shared_ptr<Asset> > read_assetmap (bool keep_going, ReadErrors* errors) const;
-
- /** the directory that the package is in */
- boost::filesystem::path _directory;
+ /** the CPLs that make up this package */
+ std::list<boost::shared_ptr<T> > _cpls;
};
}