Program Listing for File object-map.h

Return to documentation for file (include\object-map\object-map.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 <cstdint>
#include <unordered_map>
#include <functional>

namespace gpa {
namespace playback {

class ObjectMap
{
public:
    ObjectMap();
    ~ObjectMap();

    typedef uint64_t Key;
    typedef void* ObjectRef;
    typedef uint64_t Timestamp;
    struct ObjectEntry
    {
        ObjectRef ref;
        Timestamp timestamp;
    };

    ObjectRef AcquireObject(Key key) const;

    void SetObjectMapping(Key key, ObjectRef value);

    size_t Size() const;

    void Clear();

    void Enumerate(std::function<void(Key, ObjectRef, Timestamp)> callback) const;

private:
    // Use a non-thread safe unordered map for now, since playback (the use case)
    // is single threaded.
    std::unordered_map<Key, ObjectEntry> mObjectMap;
};

}  // namespace playback
}  // namespace gpa