Jack Hansdampf / mbed-mqtt-GSOE1

Dependents:   ESP8266MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MQTTSNGWForwarder.h Source File

MQTTSNGWForwarder.h

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 
00017 #ifndef MQTTSNGATEWAY_SRC_MQTTSNGWFORWARDER_H_
00018 #define MQTTSNGATEWAY_SRC_MQTTSNGWFORWARDER_H_
00019 
00020 #include "MQTTSNGWClient.h"
00021 #include "MQTTSNGateway.h"
00022 #include "MQTTSNGWEncapsulatedPacket.h"
00023 #include "SensorNetwork.h"
00024 
00025 
00026 namespace MQTTSNGW
00027 {
00028 class Gateway;
00029 class Client;
00030 class WirelessNodeId;
00031 
00032 /*=====================================
00033      Class ForwarderElement
00034  =====================================*/
00035 class ForwarderElement
00036 {
00037     friend class Forwarder;
00038 public:
00039     ForwarderElement();
00040     ~ForwarderElement();
00041 
00042     void setClient(Client* client);
00043     void setWirelessNodeId(WirelessNodeId* id);
00044 private:
00045     Client* _client;
00046     WirelessNodeId* _wirelessNodeId;
00047     ForwarderElement* _next;
00048 };
00049 
00050 /*=====================================
00051      Class Forwarder
00052  =====================================*/
00053 class Forwarder
00054 {
00055     friend class ForwarderList;
00056 public:
00057     Forwarder(void);
00058     Forwarder(SensorNetAddress* addr,  MQTTSNString* forwarderId);
00059     ~Forwarder();
00060 
00061     void initialize(void);
00062     const char* getId(void);
00063     void addClient(Client* client, WirelessNodeId* id);
00064     Client* getClient(WirelessNodeId* id);
00065     WirelessNodeId* getWirelessNodeId(Client* client);
00066     void eraseClient(Client* client);
00067     SensorNetAddress* getSensorNetAddr(void);
00068     const char* getName(void);
00069 
00070 private:
00071     string _forwarderName;
00072     SensorNetAddress _sensorNetAddr;
00073     ForwarderElement* _headClient{nullptr};
00074     Forwarder* _next {nullptr};
00075     Mutex _mutex;
00076 };
00077 
00078 /*=====================================
00079      Class ForwarderList
00080  =====================================*/
00081 class ForwarderList
00082 {
00083 public:
00084     ForwarderList();
00085     ~ForwarderList();
00086 
00087     void initialize(Gateway* gw);
00088     Forwarder* getForwarder(SensorNetAddress* addr);
00089     Forwarder* addForwarder(SensorNetAddress* addr,  MQTTSNString* forwarderId);
00090 
00091 private:
00092     Forwarder* _head;
00093 };
00094 
00095 }
00096 
00097 
00098 
00099 #endif /* MQTTSNGATEWAY_SRC_MQTTSNGWFORWARDER_H_ */