Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MQTTSNGWTopic.h
00001 /************************************************************************************** 00002 * Copyright (c) 2016, Tomoaki Yamaguchi 00003 * 00004 * All rights reserved. This program and the accompanying materials 00005 * are made available under the terms of the Eclipse Public License v1.0 00006 * and Eclipse Distribution License v1.0 which accompany this distribution. 00007 * 00008 * The Eclipse Public License is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * and the Eclipse Distribution License is available at 00011 * http://www.eclipse.org/org/documents/edl-v10.php. 00012 * 00013 * Contributors: 00014 * Tomoaki Yamaguchi - initial API and implementation and/or initial documentation 00015 * Tieto Poland Sp. z o.o. - Gateway improvements 00016 **************************************************************************************/ 00017 00018 #ifndef MQTTSNGATEWAY_SRC_MQTTSNGWTOPIC_H_ 00019 #define MQTTSNGATEWAY_SRC_MQTTSNGWTOPIC_H_ 00020 00021 #include "MQTTSNGWPacket.h" 00022 #include "MQTTSNPacket.h" 00023 00024 namespace MQTTSNGW 00025 { 00026 00027 00028 /*===================================== 00029 Class Topic 00030 ======================================*/ 00031 class Topic 00032 { 00033 friend class Topics; 00034 public: 00035 Topic(); 00036 Topic(string* topic, MQTTSN_topicTypes type); 00037 ~Topic(); 00038 string* getTopicName(void); 00039 uint16_t getTopicId(void); 00040 MQTTSN_topicTypes getType(void); 00041 bool isMatch(string* topicName); 00042 void print(void); 00043 private: 00044 MQTTSN_topicTypes _type; 00045 uint16_t _topicId; 00046 string* _topicName; 00047 Topic* _next; 00048 }; 00049 00050 /*===================================== 00051 Class Topics 00052 ======================================*/ 00053 class Topics 00054 { 00055 public: 00056 Topics(); 00057 ~Topics(); 00058 Topic* add(const MQTTSN_topicid* topicid); 00059 Topic* add(const char* topicName, uint16_t id = 0); 00060 Topic* getTopicByName(const MQTTSN_topicid* topic); 00061 Topic* getTopicById(const MQTTSN_topicid* topicid); 00062 Topic* match(const MQTTSN_topicid* topicid); 00063 void eraseNormal(void); 00064 uint16_t getNextTopicId(); 00065 void print(void); 00066 uint8_t getCount(void); 00067 private: 00068 uint16_t _nextTopicId; 00069 Topic* _first; 00070 uint8_t _cnt; 00071 }; 00072 00073 /*===================================== 00074 Class TopicIdMapElement 00075 =====================================*/ 00076 class TopicIdMapElement 00077 { 00078 friend class TopicIdMap; 00079 public: 00080 TopicIdMapElement(uint16_t msgId, uint16_t topicId, MQTTSN_topicTypes type); 00081 ~TopicIdMapElement(); 00082 MQTTSN_topicTypes getTopicType(void); 00083 uint16_t getTopicId(void); 00084 00085 private: 00086 uint16_t _msgId; 00087 uint16_t _topicId; 00088 MQTTSN_topicTypes _type; 00089 TopicIdMapElement* _next; 00090 TopicIdMapElement* _prev; 00091 }; 00092 00093 class TopicIdMap 00094 { 00095 public: 00096 TopicIdMap(); 00097 ~TopicIdMap(); 00098 TopicIdMapElement* getElement(uint16_t msgId); 00099 TopicIdMapElement* add(uint16_t msgId, uint16_t topicId, MQTTSN_topicTypes type); 00100 void erase(uint16_t msgId); 00101 void clear(void); 00102 private: 00103 uint16_t* _msgIds; 00104 TopicIdMapElement* _first; 00105 TopicIdMapElement* _end; 00106 int _cnt; 00107 int _maxInflight; 00108 }; 00109 00110 00111 } 00112 00113 00114 00115 #endif /* MQTTSNGATEWAY_SRC_MQTTSNGWTOPIC_H_ */
Generated on Wed Jul 13 2022 10:46:03 by
1.7.2