norian: (Default)
[personal profile] norian
Гибридная Графовая База Данных (отвертка с моторчиком для моделирования моделей)

День 6. Метаданные : регистрация типов узлов данных и линков.

Центральное хранилище данных о типах/блюпринтах узлов данных и линков. Здесь же находится API для создания блюпринтов.

Создание блюпринта (узла данных или линка) приложением выглядит как

graphDB.CreateNodeBlueprint("myDataNodes");
graphDB.AddNodeDataField("name");
graphDB.AddNodeDataField("cornerX");
graphDB.AddNodeDataField("cornerY");
graphDB.CommitNodeBlueprint();


API для всех операций создания блюпринтов для узлов данных и линков имплементировано в классе EgDatabaseType. Одно кольцо чтобы рулить всем.

source egDatabaseType.h

#pragma once
#include <iostream>
#include <unordered_map>

#include "../nodes/egDataNodesType.h"

const std::string nodesTypesStorageName("egNodesTypesMetainfo");
const std::string linksTypesStorageName("egLinksTypesMetainfo");
const std::string layersStorageName    ("egLayersTypesMetainfo");

class EgDatabaseType {
public:
    EgDataNodesType nodesTypesMetainfo;
    EgDataNodesType linksTypesMetainfo;
    EgDataNodesType layersMetainfo;
    bool nodesTypesMetainfoLoaded {false};
    bool linksTypesMetainfoLoaded {false};
    bool layersMetainfoLoaded     {false};    

    EgDataNodeBlueprintType* nodeBlueprint {nullptr};
    EgDataNodeBlueprintType* linkBlueprint {nullptr};
    EgDataNodeBlueprintType* layersBlueprint {nullptr};
    bool CreateNodeBlueprintFlag {false};
    bool CreateLinkBlueprintFlag {false};

    EgDatabaseType() { initDatabase(); }
    
    ~EgDatabaseType() { 
        clear(); 
        /*delete nodesTypesStorageBlueprint; delete linksTypesStorageBlueprint; delete nodesTypesStorage; delete linksTypesStorage; */
    }
    
    void clear();

    void initDatabase();
    void initNodesMetainfo();
    void initLinksMetainfo();
    void initLayersMetainfo();

    EgDataNodesType* GetNodesTypePtrByID(EgBlueprintIDType nodeTypeID);
// ======================== nodes metadata ========================
    void AddDataNodesTypeInfo(EgBlueprintIDType& blueprintID, const std::string& typeName);
    int  LoadDataNodesTypesInfo();
    int  StoreDataNodesTypesInfo();
    bool nodeTypeIDByName(const std::string& typeName, EgBlueprintIDType& nodeTypeID);
    EgDataNode* dataNodePtrByNodesType(EgDataNodesType* nodesType);    

    int  CreateNodeBlueprint(const std::string& blueprintName);
    void AddNodeDataField   (const std::string& fieldName);
    void AddIndex(const std::string& indexName, uint8_t indexSizeBytes = 4, uint8_t indexSubType = egIndexesSpace::egIntFT);
    void CommitNodeBlueprint();         // use AddNodeDataField() prior to commit
    void CommitSystemNodeBlueprint();   // dont add info to blueprints metadata storage (e.g. to create system storages)
// ======================== links metadata ========================
    void AddLinksTypeInfo(EgBlueprintIDType& blueprintID, const std::string& linksTypeName);
    int  LoadLinksInfo();
    int  StoreLinksInfo();
    bool linkTypeIDByName(const std::string& linkName, EgBlueprintIDType& linkTypeID);

    int  CreateLinkBlueprint(const std::string& linkTypeName, const std::string& nodesFrom, const std::string& nodesTo); // between 2 (1) node types only
    int  CreateLinkWithDataBlueprint(const std::string& linkTypeName, const std::string& nodesFrom, const std::string& nodesTo);
    void AddLinkDataField(const std::string& fieldName);
    void CommitLinkBlueprint(); // use AddLinkDataField() to add fields prior to commit

    int  CreateFreeLinkBlueprint(const std::string& linkTypeName) { /* FIXME TODO */ return 0; } // between any node types, 4 IDs per link
    int  CreateFreeLinkWithDataBlueprint(const std::string& linkTypeName) { /* FIXME TODO */ return 0; }
// ======================== layers metadata ========================
    void AddLayersTypeInfo(EgBlueprintIDType& blueprintID, const std::string& linksTypeName);
    int  LoadLayersInfo();
    int  StoreLayersInfo();
    bool layersTypeIDByName(const std::string& layersName, EgBlueprintIDType& layersTypeID);

    int CreateLayersBlueprint(const std::string& layersTypeName);
    // FIXME TODO : delete nodes, links, layers metadata
};

Profile

norian: (Default)
Norian

January 2026

S M T W T F S
    1 2 3
456 78 910
11121314 151617
18 19 20 21 22 23 24
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 24th, 2026 09:00 pm
Powered by Dreamwidth Studios