Files
spark/src/lib/md/SecurityStore.h
T

46 lines
1.1 KiB
C++

#pragma once
#include "MDConsumerHandle.h"
#include "lib/api/domain/Venue.pb.h"
#include "lib/api/domain/SecurityType.pb.h"
#include "lib/domain/SecurityID.h"
#include <memory>
namespace bts::domain {
class Security;
}
namespace bts::md {
class SecurityStore {
public:
using SecurityPtr = std::shared_ptr<domain::Security>;
SecurityStore();
~SecurityStore();
// Load security from cache with fallback to database
const domain::Security *get_security(domain::SecurityID id);
// Load all securities from cache, no fallback to database
std::vector<domain::Security const *> get_securities();
// Get the security if it's in the cache otherwise return nullptr. Does not
// query security database.
const domain::Security *try_get_security(domain::SecurityID key) const;
// returns true if the cache was updated
bool add_security(
api::domain::Venue venue,
api::domain::SecurityType type,
const std::string &symbol);
const domain::Security *add_db_security(const SecurityPtr &security);
void flush_to_disk();
private:
struct PImpl;
std::shared_ptr<PImpl> me_;
};
} // namespace bts::md