sapling/cstore/py-structs.h
Durham Goode a79aa29030 cstore: move uniondatapackstore holder to be a shared_ptr
Summary:
In a future patch we will want to pass the uniondatapackstore around to other
objects who will contribute to the lifetime. Let's change it to a shared_ptr so
that becomes easy.

Let's also make the destructor virtual, so we can pass different types of stores
around and have them be destructed correctly.

Test Plan: Ran the tests

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4603893

Signature: t1:4603893:1487847173:2fc3505032ea8c30cf9e0f76ac4e75d64513d87d
2017-02-23 14:03:04 -08:00

34 lines
711 B
C++

// py-structs.h - c++ headers for store python objects
//
// Copyright 2017 Facebook, Inc.
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
//
// no-check-code
#ifndef CSTORE_PY_STRUCTS
#define CSTORE_PY_STRUCTS
#include <memory>
#include "datapackstore.h"
#include "uniondatapackstore.h"
struct py_datapackstore {
PyObject_HEAD;
DatapackStore datapackstore;
};
struct py_uniondatapackstore {
PyObject_HEAD;
std::shared_ptr<UnionDatapackStore> uniondatapackstore;
// Keep a reference to the python objects so we can decref them later.
std::vector<PythonObj> substores;
};
#endif //CSTORE_PY_STRUCTS