Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef __ctrlplane__ifmap_link_table__ 7 : #define __ctrlplane__ifmap_link_table__ 8 : 9 : #include "db/db_graph_base.h" 10 : #include "db/db_graph_table.h" 11 : 12 : struct IFMapOrigin; 13 : class DBGraph; 14 : class IFMapLink; 15 : class IFMapNode; 16 : class IFMapTable; 17 : 18 : class IFMapLinkTable : public DBGraphTable { 19 : public: 20 : static const int kPartitionCount = 1; 21 : struct RequestKey : DBRequestKey { 22 : std::string name; 23 : }; 24 : struct RequestData : DBRequestData { 25 : // Intentionally left blank. 26 : }; 27 : 28 : IFMapLinkTable(DB *db, const std::string &name, DBGraph *graph); 29 : 30 16440 : virtual int PartitionCount() const { 31 16440 : return kPartitionCount; 32 : } 33 : 34 : // The Link table is modified from the IFMapTable code directly. Its input 35 : // method should never be called. 36 : virtual void Input(DBTablePartition *partition, DBClient *client, 37 : DBRequest *req); 38 : 39 : std::string LinkKey(const std::string &metadata, IFMapNode *left, 40 : IFMapNode *right); 41 : IFMapLink *AddLink(IFMapNode *left, IFMapNode *right, 42 : const std::string &metadata, uint64_t sequence_number, 43 : const IFMapOrigin &origin); 44 : void DeleteLink(IFMapLink *link, const IFMapOrigin &origin); 45 : void DeleteLink(IFMapLink *link); 46 : 47 : virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *key) const; 48 : 49 : void Clear(); 50 : 51 : static DBTable *CreateTable(DB *db, const std::string &name, 52 : DBGraph *graph); 53 : IFMapLink *FindLink(const std::string &metadata, IFMapNode *left, IFMapNode *right); 54 : IFMapLink *FindLink(const std::string &name); 55 : IFMapLink *FindNextLink(const std::string &name); 56 : }; 57 : 58 : extern void IFMapLinkTable_Init(DB *db, DBGraph *graph); 59 : extern void IFMapLinkTable_Clear(DB *db); 60 : 61 : #endif /* defined(__ctrlplane__ifmap_link_table__) */