Files
o3de/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetReference.h
T
Steve Pham b4a2edec6a Final update copyright headers to reference license files at the repo root (#1693)
* Final update copyright headers to reference license files at the repo root

Signed-off-by: spham <spham@amazon.com>

* Fix copyright validator unit tests to support the stale O3DE header scenario

Signed-off-by: spham <spham@amazon.com>
2021-06-30 19:51:55 -07:00

71 lines
2.5 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/Serialization/DataPatch.h>
#include <AzCore/Asset/AssetCommon.h>
namespace ScriptCanvas
{
class ScriptCanvasData;
}
namespace ScriptCanvasEditor
{
class ScriptCanvasAsset;
class ScriptCanvasAssetReference
{
public:
AZ_TYPE_INFO(ScriptCanvasAssetReference, "{C1B24507-887C-4E20-A259-BFEEDD7EDF9D}");
AZ_CLASS_ALLOCATOR(ScriptCanvasAssetReference, AZ::SystemAllocator, 0);
ScriptCanvasAssetReference() = default;
ScriptCanvasAssetReference(AZ::Data::Asset<ScriptCanvasAsset> scriptCanvasAsset, bool storeInObjectStream = false);
static void Reflect(AZ::ReflectContext* context);
/*!
\param scriptCanvasAsset asset reference to store
\param storeInObjectStream bool which determines if the asset data will serialized out as part of the ObjectStream when serializing
*/
void SetAsset(AZ::Data::Asset<ScriptCanvasAsset> scriptCanvasAsset);
const AZ::Data::Asset<ScriptCanvasAsset>& GetAsset() const;
AZ::Data::Asset<ScriptCanvasAsset>& GetAsset();
/*!
\param storeInObjectStream bool which determines if the asset data will serialized out as part of the ObjectStream when serializing
*/
void SetAssetDataStoredInternally(bool storeInObjectStream);
/*!
Indicates if this scriptCanvas reference contains an asset whose data is stored internally in this class.
\return true if the asset is asset data is serialize as part of this class object stream
*/
bool GetAssetDataStoredInternally() const;
private:
bool m_storeInObjectStream = false; ///< If true the asset data is stored in the object stream with this class
AZ::Data::Asset<ScriptCanvasAsset> m_asset;
friend class ScriptCanvasAssetReferenceContainer;
};
}
namespace AZStd
{
template<>
struct hash<ScriptCanvasEditor::ScriptCanvasAssetReference>
{
using argument_type = ScriptCanvasEditor::ScriptCanvasAssetReference;
using result_type = AZStd::size_t;
AZ_FORCE_INLINE size_t operator()(const argument_type& key) const
{
AZStd::hash<AZ::Data::AssetId> hasher;
return hasher(key.GetAsset().GetId());
}
};
}