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.
MQTTSNGWAggregateTopicTable.cpp
00001 /************************************************************************************** 00002 * Copyright (c) 2018, 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 **************************************************************************************/ 00016 #include "MQTTSNGWAggregateTopicTable.h" 00017 #include "MQTTSNGWClient.h" 00018 00019 /*===================================== 00020 Class ClientTopicElement 00021 =====================================*/ 00022 ClientTopicElement::ClientTopicElement(Client* client) 00023 { 00024 _client = client; 00025 } 00026 00027 ClientTopicElement::~ClientTopicElement() 00028 { 00029 00030 } 00031 00032 Client* ClientTopicElement::getClient(void) 00033 { 00034 return _client; 00035 } 00036 00037 /*===================================== 00038 Class AggregateTopicElement 00039 =====================================*/ 00040 AggregateTopicElement::AggregateTopicElement(void) 00041 { 00042 00043 } 00044 00045 AggregateTopicElement::AggregateTopicElement(Topic* topic, Client* client) 00046 { 00047 ClientTopicElement* elm = new ClientTopicElement(client); 00048 if ( elm != nullptr ) 00049 { 00050 _head = elm; 00051 _tail = elm; 00052 } 00053 } 00054 00055 AggregateTopicElement::~AggregateTopicElement(void) 00056 { 00057 _mutex.lock(); 00058 if ( _head != nullptr ) 00059 { 00060 ClientTopicElement* p = _tail; 00061 while ( p ) 00062 { 00063 ClientTopicElement* pPrev = p; 00064 delete p; 00065 p = pPrev->_prev; 00066 } 00067 _head = _tail = nullptr; 00068 } 00069 _mutex.unlock(); 00070 } 00071 00072 ClientTopicElement* AggregateTopicElement::add(Client* client) 00073 { 00074 ClientTopicElement* elm = new ClientTopicElement(client); 00075 if ( elm == nullptr ) 00076 { 00077 return nullptr; 00078 } 00079 _mutex.lock(); 00080 if ( _head == nullptr ) 00081 { 00082 _head = elm; 00083 _tail = elm; 00084 } 00085 else 00086 { 00087 ClientTopicElement* p = find(client); 00088 if ( p == nullptr ) 00089 { 00090 p = _tail; 00091 _tail = elm; 00092 elm->_prev = p; 00093 p->_next = elm; 00094 } 00095 else 00096 { 00097 delete elm; 00098 elm = nullptr; 00099 } 00100 } 00101 _mutex.unlock(); 00102 return elm; 00103 } 00104 00105 ClientTopicElement* AggregateTopicElement::find(Client* client) 00106 { 00107 ClientTopicElement* p = _head; 00108 while ( p ) 00109 { 00110 if ( p->_client == client) 00111 { 00112 break; 00113 } 00114 p = p->_next; 00115 } 00116 return p; 00117 } 00118 00119 ClientTopicElement* AggregateTopicElement::getFirstElement(void) 00120 { 00121 return _head; 00122 } 00123 00124 ClientTopicElement* AggregateTopicElement::getNextElement(ClientTopicElement* elm) 00125 { 00126 return elm->_next; 00127 } 00128 00129 00130 /*===================================== 00131 Class AggregateTopicTable 00132 ======================================*/ 00133 00134 AggregateTopicTable::AggregateTopicTable() 00135 { 00136 00137 } 00138 00139 AggregateTopicTable::~AggregateTopicTable() 00140 { 00141 00142 } 00143 00144 AggregateTopicElement* AggregateTopicTable::add(Topic* topic, Client* client) 00145 { 00146 //ToDo: AggregateGW 00147 return 0; 00148 } 00149 00150 void AggregateTopicTable::remove(Topic* topic, Client* client) 00151 { 00152 //ToDo: AggregateGW 00153 } 00154 00155 AggregateTopicElement* AggregateTopicTable::getClientList(Topic* client) 00156 { 00157 // ToDo: AggregateGW 00158 return 0; 00159 } 00160 00161
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2