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.
Fork of kpn_senml by
senml_base.cpp
00001 00002 /* _ __ ____ _ _ 00003 * | |/ / | _ \ | \ | | 00004 * | ' / | |_) | | \| | 00005 * | . \ | __/ | |\ | 00006 * |_|\_\ |_| |_| \_| 00007 * 00008 * (c) 2018 KPN 00009 * License: MIT License. 00010 * Author: Jan Bogaerts 00011 * 00012 * base class for all senml objects 00013 */ 00014 00015 00016 #include <senml_base.h> 00017 #include <senml_pack.h> 00018 00019 00020 SenMLBase::SenMLBase(): _prev(NULL), _next(NULL) 00021 { 00022 } 00023 00024 SenMLBase::~SenMLBase() 00025 { 00026 if(this->_prev) 00027 this->_prev->setNext(this->_next); 00028 if(this->_next) 00029 this->_next->setPrev(this->_prev); 00030 00031 } 00032 00033 void SenMLBase::setNext(SenMLBase* value) 00034 { 00035 if(value == NULL){ //if next becomes null and there is a root, then this object became the last in the list, so let the root know. 00036 SenMLPack* root = (SenMLPack*)this->getRoot(); 00037 if(root) 00038 root->setLast(this); 00039 } 00040 this->_next = value; 00041 } 00042 00043 void SenMLBase::setPrev(SenMLBase* value) 00044 { 00045 this->_prev = value; 00046 } 00047 00048 SenMLBase* SenMLBase::getPrev() 00049 { 00050 return this->_prev; 00051 } 00052 00053 SenMLBase* SenMLBase::getRoot() 00054 { 00055 SenMLBase* prev = this->_prev; 00056 while(prev){ 00057 SenMLBase* newPrev = prev->getPrev(); 00058 if(newPrev == NULL) 00059 return prev; 00060 else 00061 prev = newPrev; 00062 } 00063 return this; //if there was no first prev, it means we are root. 00064 } 00065 00066 00067 00068 00069 00070 00071 00072
Generated on Tue Jul 12 2022 23:07:21 by
