use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 04:01:34 2016 +0000
Revision:
27:b8aaf7dc7023
Child:
38:bb6d2be4d54c
Initial merge and update of device and firmware objects

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 27:b8aaf7dc7023 1 /**
ansond 27:b8aaf7dc7023 2 * @file NamedPointer.cpp
ansond 27:b8aaf7dc7023 3 * @brief mbed CoAP Endpoint Device Management Named Pointer
ansond 27:b8aaf7dc7023 4 * @author Doug Anson
ansond 27:b8aaf7dc7023 5 * @version 1.0
ansond 27:b8aaf7dc7023 6 * @see
ansond 27:b8aaf7dc7023 7 *
ansond 27:b8aaf7dc7023 8 * Copyright (c) 2016
ansond 27:b8aaf7dc7023 9 *
ansond 27:b8aaf7dc7023 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 27:b8aaf7dc7023 11 * you may not use this file except in compliance with the License.
ansond 27:b8aaf7dc7023 12 * You may obtain a copy of the License at
ansond 27:b8aaf7dc7023 13 *
ansond 27:b8aaf7dc7023 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 27:b8aaf7dc7023 15 *
ansond 27:b8aaf7dc7023 16 * Unless required by applicable law or agreed to in writing, software
ansond 27:b8aaf7dc7023 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 27:b8aaf7dc7023 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 27:b8aaf7dc7023 19 * See the License for the specific language governing permissions and
ansond 27:b8aaf7dc7023 20 * limitations under the License.
ansond 27:b8aaf7dc7023 21 */
ansond 27:b8aaf7dc7023 22
ansond 27:b8aaf7dc7023 23 // Base Class
ansond 27:b8aaf7dc7023 24 #include "mbed-connector-interface/ObjectInstanceManager.h"
ansond 27:b8aaf7dc7023 25
ansond 27:b8aaf7dc7023 26 // constructor
ansond 27:b8aaf7dc7023 27 NamedPointer::NamedPointer(string name,void *ptr) {
ansond 27:b8aaf7dc7023 28 this->m_name = name;
ansond 27:b8aaf7dc7023 29 this->m_ptr = ptr;
ansond 27:b8aaf7dc7023 30 this->m_list = (void *)new NamedPointerList();
ansond 27:b8aaf7dc7023 31 }
ansond 27:b8aaf7dc7023 32
ansond 27:b8aaf7dc7023 33 // copy constructor
ansond 27:b8aaf7dc7023 34 NamedPointer::NamedPointer(const NamedPointer &np) {
ansond 27:b8aaf7dc7023 35 this->m_name = np.m_name;
ansond 27:b8aaf7dc7023 36 this->m_ptr = np.m_ptr;
ansond 27:b8aaf7dc7023 37 this->m_list = this->copyList(np.m_list);
ansond 27:b8aaf7dc7023 38 }
ansond 27:b8aaf7dc7023 39
ansond 27:b8aaf7dc7023 40 // Destructor
ansond 27:b8aaf7dc7023 41 NamedPointer::~NamedPointer() {
ansond 27:b8aaf7dc7023 42 NamedPointerList *list = (NamedPointerList *)this->m_list;
ansond 27:b8aaf7dc7023 43 if (list != NULL) {
ansond 27:b8aaf7dc7023 44 delete list;
ansond 27:b8aaf7dc7023 45 }
ansond 27:b8aaf7dc7023 46 }
ansond 27:b8aaf7dc7023 47
ansond 27:b8aaf7dc7023 48 // Get the Name
ansond 27:b8aaf7dc7023 49 string NamedPointer::name() {
ansond 27:b8aaf7dc7023 50 return this->m_name;
ansond 27:b8aaf7dc7023 51 }
ansond 27:b8aaf7dc7023 52
ansond 27:b8aaf7dc7023 53 // Get the Pointer
ansond 27:b8aaf7dc7023 54 void *NamedPointer::ptr() {
ansond 27:b8aaf7dc7023 55 return this->m_ptr;
ansond 27:b8aaf7dc7023 56 }
ansond 27:b8aaf7dc7023 57
ansond 27:b8aaf7dc7023 58 // Get any associated list
ansond 27:b8aaf7dc7023 59 void *NamedPointer::list() {
ansond 27:b8aaf7dc7023 60 return this->m_list;
ansond 27:b8aaf7dc7023 61 }
ansond 27:b8aaf7dc7023 62
ansond 27:b8aaf7dc7023 63 // Copy the list
ansond 27:b8aaf7dc7023 64 void *NamedPointer::copyList(void *list) {
ansond 27:b8aaf7dc7023 65 NamedPointerList *npl = new NamedPointerList();
ansond 27:b8aaf7dc7023 66 NamedPointerList *tmp_list = (NamedPointerList *)list;
ansond 27:b8aaf7dc7023 67 for(int i=0;tmp_list != NULL && i<tmp_list->size();++i) {
ansond 27:b8aaf7dc7023 68 npl->push_back(tmp_list->at(i));
ansond 27:b8aaf7dc7023 69 }
ansond 27:b8aaf7dc7023 70 return (void *)npl;
ansond 27:b8aaf7dc7023 71 }
ansond 27:b8aaf7dc7023 72