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_encoder__ 7 : #define __ctrlplane__ifmap_encoder__ 8 : 9 : #include <pugixml/pugixml.hpp> 10 : 11 : class IFMapNode; 12 : class IFMapLink; 13 : class IFMapUpdate; 14 : 15 : class IFMapMessage { 16 : public: 17 : static const int kObjectsPerMessage = 16; 18 : IFMapMessage(); 19 : 20 : void Close(); 21 : // set the 'to' field in the message 22 : void SetReceiverInMsg(const std::string &cli_identifier); 23 : void SetObjectsPerMessage(int num); 24 : void EncodeUpdate(const IFMapUpdate *update); 25 : bool IsFull(); 26 : bool IsEmpty(); 27 : void Reset(); 28 : 29 116 : const std::string &get_string() const { return str_; } 30 : 31 : private: 32 : enum Op { 33 : NONE, 34 : UPDATE, 35 : DEL 36 : }; 37 : void Open(); 38 : void EncodeNode(const IFMapUpdate *update); 39 : void EncodeLink(const IFMapUpdate *update); 40 : 41 : pugi::xml_document doc_; 42 : pugi::xml_node config_; 43 : Op op_type_; // the current type of op_node_ 44 : pugi::xml_node op_node_; 45 : std::string str_; 46 : int node_count_; 47 : int objects_per_message_; 48 : }; 49 : 50 : #endif /* defined(__ctrlplane__ifmap_encoder__) */