pgLab/pglablib/ui/catalog/tables/TableTreeBuilder.h
eelke 39dbab4d36 The table inheritance works mostly
When a table has partitions or inheritance children these are listed as subnodes. A subnode can appear multiple times under different parents as postgresql supports inheriting multiple tables.

The sizes are still missing and maybe some things I have note verified yet are not correct.
2023-01-22 15:57:22 +01:00

32 lines
891 B
C++

#pragma once
#include "Pgsql_oids.h"
#include <map>
#include <memory>
class PgClass;
class TableNode;
class IFindParents;
class TableTreeBuilder
{
public:
TableTreeBuilder(const std::map<Oid, PgClass> &source, const IFindParents &inheritance);
std::shared_ptr<TableNode> Build();
private:
const std::map<Oid, PgClass> &source;
const IFindParents &inheritance;
std::map<Oid, std::shared_ptr<TableNode>> processedNodes;
std::shared_ptr<TableNode> rootNode;
void resetState();
bool hasParent(const PgClass &cls) const;
std::shared_ptr<TableNode> addNode(const PgClass &cls);
void addToplevelNode(std::shared_ptr<TableNode> node);
void addToParents(std::shared_ptr<TableNode> node, const std::vector<Oid> &parents);
std::shared_ptr<TableNode> getParent(Oid oid);
void AssignNodeIndexesAndParents(std::shared_ptr<TableNode> parent);
};