/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
files in the program, then also delete it here.
*/
+
/** @file src/ref.h
- * @brief Ref class.
+ * @brief Ref class
*/
+
#ifndef LIBDCP_REF_H
#define LIBDCP_REF_H
+
#include "exceptions.h"
#include "asset.h"
#include "util.h"
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include <string>
+
namespace dcp {
+
/** @class Ref
- * @brief A reference to an asset which is identified by a universally-unique identifier (UUID).
+ * @brief A reference to an asset which is identified by a universally-unique identifier (UUID)
*
* This class is a `pointer' to a thing. It will always know the
* UUID of the thing, and it may have a shared_ptr to the C++ object
* which represents the thing.
*
* If the Ref does not have a shared_ptr it may be given one by
- * calling resolve() with a list of assets. The shared_ptr will be
- * set up using any object on the list which has a matching ID.
+ * calling resolve() with a vector of assets. The shared_ptr will be
+ * set up using any object on the vector which has a matching ID.
*/
class Ref
{
{}
/** Initialise a Ref with a shared_ptr to an asset */
- explicit Ref (boost::shared_ptr<Asset> asset)
+ explicit Ref (std::shared_ptr<Asset> asset)
: _id (asset->id ())
, _asset (asset)
{}
_id = id;
}
- void resolve (std::list<boost::shared_ptr<Asset> > assets);
+ /** Look through a list of assets and copy a shared_ptr to any asset
+ * which matches the ID of this one
+ */
+ void resolve (std::vector<std::shared_ptr<Asset>> assets);
/** @return the ID of the thing that we are pointing to */
std::string id () const {
}
/** @return a shared_ptr to the thing; an UnresolvedRefError is thrown
- * if the shared_ptr is not known.
+ * if the shared_ptr is not known
*/
- boost::shared_ptr<Asset> asset () const {
+ std::shared_ptr<Asset> asset () const {
if (!_asset) {
throw UnresolvedRefError (_id);
}
}
/** operator-> to access the shared_ptr; an UnresolvedRefError is thrown
- * if the shared_ptr is not known.
+ * if the shared_ptr is not known
*/
Asset * operator->() const {
if (!_asset) {
private:
std::string _id; ///< ID; will always be known
- boost::shared_ptr<Asset> _asset; ///< shared_ptr to the thing, may be null.
+ std::shared_ptr<Asset> _asset; ///< shared_ptr to the thing, may be null.
};
+
}
+
#endif