Program Listing for File api-log.h

Return to documentation for file (include\playback\api-log.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 "playback/callable-cache.h"
#include "playback/stream-data-bookmark.h"

#include <cstdint>
#include <vector>

namespace gpa {

namespace serialization {
class Stream;
struct GPAToken;
}  // namespace serialization
namespace memory {
class Allocator;
}

namespace playback {

class StreamData;

class ApiLog
{
public:
    ApiLog(serialization::Stream* stream, serialization::GPAToken const* delimiters = nullptr,
           memory::Allocator* allocator = nullptr);

    ApiLog(playback::StreamData* streamData, serialization::GPAToken const* delimiters = nullptr);

    ~ApiLog();

    uint64_t ScanForRanges(uint64_t limit = UINT64_MAX);

    uint64_t RangeCount() const;

    CallableCache Range(uint64_t index) const;

    CallableCache Ranges(uint64_t first, uint64_t last) const;

    StreamDataBookmark RangeBookmark(uint64_t index) const;

    StreamDataBookmark RangeBookmarkEnd(uint64_t index) const;

    StreamDataBookmark RangeBookmarkEndWithDelimiter(uint64_t index) const;

    void AllowIncompleteRanges(bool allow);

private:
    StreamData* mStreamData;
    StreamData* mAllocatedData;
    memory::Allocator* mAllocator;
    memory::Allocator* mDefaultAllocator;
    std::vector<serialization::GPAToken> mDelimiters;
    std::vector<StreamDataBookmark> mRangeStartBookmarks;
    std::vector<StreamDataBookmark> mRangeEndBookmarks;
    std::vector<StreamDataBookmark> mRangeEndDelimiterBookmarks;
    bool mAllowIncompleteRanges;

    CallableCache CollectRange(const StreamDataBookmark& begin, const StreamDataBookmark& end) const;
    void InitializeDelimiters(serialization::GPAToken const* delimiters);

    ApiLog(ApiLog const&) = delete;
    ApiLog& operator=(ApiLog const&) = delete;
};

}  // namespace playback
}  // namespace gpa