Program Listing for File range-analyzer.h

Return to documentation for file (include\playback\range-analyzer.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 "igpa-config.h"
#include <stdint.h>
#include <vector>

namespace gpa {

namespace serialization {
struct GPAToken;
}

namespace playback {

class Callable;
class CallableCache;
class StreamData;

struct CallMapping
{
    uint64_t originalCallIndex;
    uint64_t processedCallIndex;
    Callable* callable;
};

class RangeAnalyzer
{
public:
    RangeAnalyzer(CallableCache* originalCache, CallableCache* flattenedCache, serialization::GPAToken const* delimiters = nullptr, size_t delimitersCount = 0);
    ~RangeAnalyzer();

    uint64_t FindCallAtIndex(uint64_t originalCacheCallIndex);

    uint64_t FindCallAtDelimiter(uint64_t delimiterIndex);

    void FindDelimiters(CallMapping const** foundDelimiters, size_t* foundDelimitersCount);

private:
    void FindDelimiters();

    CallableCache* mOriginalCache;
    CallableCache* mFlattenedCache;

    std::vector<serialization::GPAToken> mDelimiters;
    std::vector<CallMapping> mDelimitersMapping;
};

class FlattenedRangeAnalyzer
{
public:
    enum class Rounding {
        ROUND_UP,
        ROUND_DOWN,
        EXACT_MATCH,
    };

    FlattenedRangeAnalyzer(CallableCache* flattenedCache, StreamData* streamData);

    uint64_t SearchRangeForCallFromStream(uint64_t absoluteCallIndex);

    uint64_t SearchRangeForCallFromStream(uint64_t timestamp, uint64_t storageID, Rounding rounding = Rounding::ROUND_UP);

private:
    CallableCache* mFlattenedCache;
    StreamData* mStreamData;
};

}  // namespace playback
}  // namespace gpa