sapling/eden/fs/testharness/FakeObjectStore.h
Wez Furlong 0a6aa21d77 eden: fix multiply defined symbols issue with ImportPriority
Summary:
This is a rough pass that resolves a linker issue on MSVC by
switching to inline static member functions.

Reviewed By: chadaustin

Differential Revision: D20529163

fbshipit-source-id: 578ed440758c685091d3e039e261638e027db17a
2020-03-20 10:56:08 -07:00

67 lines
2.1 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <unordered_map>
#include "eden/fs/store/IObjectStore.h"
#include "eden/fs/model/Blob.h"
#include "eden/fs/model/Hash.h"
#include "eden/fs/model/Tree.h"
#include "eden/fs/store/BlobMetadata.h"
#include "eden/fs/store/ImportPriority.h"
namespace facebook {
namespace eden {
/**
* Fake implementation of IObjectStore that allows the data to be injected
* directly. This is designed to be used for unit tests.
*/
class FakeObjectStore : public IObjectStore {
public:
FakeObjectStore();
~FakeObjectStore() override;
void addTree(Tree&& tree);
void addBlob(Blob&& blob);
void setTreeForCommit(const Hash& commitID, Tree&& tree);
folly::Future<std::shared_ptr<const Tree>> getTree(
const Hash& id,
ObjectFetchContext& context =
ObjectFetchContext::getNullContext()) const override;
folly::Future<std::shared_ptr<const Blob>> getBlob(
const Hash& id,
ObjectFetchContext& context = ObjectFetchContext::getNullContext(),
ImportPriority priority = ImportPriority::kNormal()) const override;
folly::Future<std::shared_ptr<const Tree>> getTreeForCommit(
const Hash& commitID,
ObjectFetchContext& context =
ObjectFetchContext::getNullContext()) const override;
folly::Future<std::shared_ptr<const Tree>> getTreeForManifest(
const Hash& commitID,
const Hash& manifestID,
ObjectFetchContext& context =
ObjectFetchContext::getNullContext()) const override;
folly::Future<folly::Unit> prefetchBlobs(
const std::vector<Hash>& ids,
ObjectFetchContext& context =
ObjectFetchContext::getNullContext()) const override;
size_t getAccessCount(const Hash& hash) const;
private:
std::unordered_map<Hash, Tree> trees_;
std::unordered_map<Hash, Blob> blobs_;
std::unordered_map<Hash, Tree> commits_;
mutable std::unordered_map<Hash, size_t> accessCounts_;
};
} // namespace eden
} // namespace facebook