Program Listing for File callable.h
↰ Return to documentation for file (include\playback\callable.h
)
/******************************************************************************
© Intel Corporation.
This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.
This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.
******************************************************************************/
#pragma once
#include "utility/enum-mask.h"
#include "utility/playback-common.h"
#include <cstdint>
#include <functional>
struct GPADispatchTable;
namespace gpa {
namespace serialization {
struct StreamPacketHeaderEx;
struct IFunctionCall;
struct GPAToken;
class Argument;
class ArgsReader;
class MemoryBackedSerializer;
} // namespace serialization
namespace memory {
class Allocator;
}
namespace playback {
struct Context;
class IPlayable;
class Callable : public playback_common::ICallable
{
public:
Callable();
Callable(serialization::StreamPacketHeaderEx const* header, memory::Allocator* allocator = nullptr);
Callable(serialization::StreamPacketHeaderEx const* header, uint64_t storageID, uint64_t storageOffset, memory::Allocator* allocator = nullptr);
Callable(Callable const& other);
Callable& operator=(Callable const& other);
~Callable();
// move ctor and operator
Callable(Callable&& other);
Callable& operator=(Callable&& other);
gpa::playback_common::CallableKey UniqueKey() const;
// Informational methods; some are non-const as their invocation may cause
// deferred initialization of the Callable
char const* Name();
char const* Class();
char const* API();
uint32_t ArgumentCount();
serialization::Argument const* Argument(uint32_t index, void const** value);
serialization::Argument const* Argument(uint32_t index, void const** value, bool postExecute);
serialization::Argument const* ReturnValue(void const** value);
void* ApiObjectPtr();
playback::Context const* Context() const;
serialization::ArgsReader const* Reader() const;
serialization::GPAToken Token() const;
uint64_t Timestamp() const;
bool IsOperation() const;
bool IsValid() const;
bool IsSuccessful(bool& success) const;
gpa::playback_common::CallableType GetCategory();
char const* GetAssociatedText();
// TEMP FOR TESTING ONLY!
bool IsDelimiter();
bool PreExecute(playback::Context* context);
bool Execute(GPADispatchTable const*& table,
bool restore = false, bool releaseResources = true, bool shouldExecute = true);
bool Ingress(GPADispatchTable const*& table, const void** params = nullptr, size_t paramCount = 0);
bool Egress(GPADispatchTable const*& table, bool releaseResources = false, uint64_t returnValue = 0);
size_t Hash() const;
uint64_t StorageID() const;
uint64_t StorageOffset() const;
serialization::IFunctionCall* GetIFunctionCall();
serialization::StreamPacketHeaderEx const* GetMappedStorageHeader();
gpa::playback_common::CallableType GetCallableType() override;
gpa::playback_common::CallableKey GetCallableKey() override;
void* GetFunctionCallPointer() override;
class AssociatedDataHelper
{
public:
AssociatedDataHelper();
AssociatedDataHelper(char const* data, bool owned);
AssociatedDataHelper(AssociatedDataHelper&& other);
AssociatedDataHelper& operator=(AssociatedDataHelper&& other);
~AssociatedDataHelper();
char const* Text() const;
private:
char const* mOwnedData;
char const* mData;
AssociatedDataHelper(AssociatedDataHelper const& other) = delete;
AssociatedDataHelper& operator=(AssociatedDataHelper const& other) = delete;
};
private:
// pointer to data in mapped storage
serialization::StreamPacketHeaderEx const* mHeader;
// pointer to specific instance of an invokable call or operation
serialization::IFunctionCall* mCallable;
// pointer to specific instance of a playable call or operation
gpa::playback::IPlayable* mPlayable;
// pointer to an ArgsReader that is created in case we need to read args data
serialization::ArgsReader* mReader;
// pointer to a Context that is set during Execute and unset during ReleaseResources
playback::Context* mContext;
// allocator used by ArgsReader
memory::Allocator* mAllocator;
// flag indicating whether arguments have been deserialized. Used to delay reading of arguments
// until needed at execution and to only read once.
bool mArgsDeserialized;
gpa::playback_common::CallableType mCategory;
uint64_t mStorageID;
uint64_t mStorageOffset;
AssociatedDataHelper mAssociatedData;
void Initialize();
bool IsActualDelimiter();
public:
void Load(serialization::MemoryBackedSerializer* resourceSerializer, bool force = false);
void ReleaseResources();
};
char const* CallableTypeToString(gpa::playback_common::CallableType type);
} // namespace playback
} // namespace gpa