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