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