mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

NOTE:

This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!

Committer:
ansond
Date:
Fri Feb 19 17:32:14 2016 +0000
Revision:
0:1f1f55e73248
Child:
33:1d0b855df5a5
initial checkin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:1f1f55e73248 1 /**
ansond 0:1f1f55e73248 2 * @file ResourceObserver.cpp
ansond 0:1f1f55e73248 3 * @brief mbed CoAP DynamicResource observer (implementation)
ansond 0:1f1f55e73248 4 * @author Doug Anson/Chris Paola
ansond 0:1f1f55e73248 5 * @version 1.0
ansond 0:1f1f55e73248 6 * @see
ansond 0:1f1f55e73248 7 *
ansond 0:1f1f55e73248 8 * Copyright (c) 2014
ansond 0:1f1f55e73248 9 *
ansond 0:1f1f55e73248 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:1f1f55e73248 11 * you may not use this file except in compliance with the License.
ansond 0:1f1f55e73248 12 * You may obtain a copy of the License at
ansond 0:1f1f55e73248 13 *
ansond 0:1f1f55e73248 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:1f1f55e73248 15 *
ansond 0:1f1f55e73248 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:1f1f55e73248 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:1f1f55e73248 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:1f1f55e73248 19 * See the License for the specific language governing permissions and
ansond 0:1f1f55e73248 20 * limitations under the License.
ansond 0:1f1f55e73248 21 */
ansond 0:1f1f55e73248 22
ansond 0:1f1f55e73248 23 #include "mbed-connector-interface/ResourceObserver.h"
ansond 0:1f1f55e73248 24
ansond 0:1f1f55e73248 25 // constructor
ansond 0:1f1f55e73248 26 ResourceObserver::ResourceObserver(DynamicResource *resource,int sleep_time) : m_is_observing(false), m_sleep_time(sleep_time) {
ansond 0:1f1f55e73248 27 this->m_resource = resource;
ansond 0:1f1f55e73248 28 if (resource != NULL) resource->setObserver(this);
ansond 0:1f1f55e73248 29 }
ansond 0:1f1f55e73248 30
ansond 0:1f1f55e73248 31 // copy constructor
ansond 0:1f1f55e73248 32 ResourceObserver::ResourceObserver(const ResourceObserver &observer) {
ansond 0:1f1f55e73248 33 this->m_resource = observer.m_resource;
ansond 0:1f1f55e73248 34 }
ansond 0:1f1f55e73248 35
ansond 0:1f1f55e73248 36 // destructor
ansond 0:1f1f55e73248 37 ResourceObserver::~ResourceObserver() {
ansond 0:1f1f55e73248 38 }
ansond 0:1f1f55e73248 39
ansond 0:1f1f55e73248 40 // get our resource
ansond 0:1f1f55e73248 41 DynamicResource *ResourceObserver::getResource() {
ansond 0:1f1f55e73248 42 return this->m_resource;
ansond 0:1f1f55e73248 43 }
ansond 0:1f1f55e73248 44
ansond 0:1f1f55e73248 45 // we are observing?
ansond 0:1f1f55e73248 46 bool ResourceObserver::isObserving() {
ansond 0:1f1f55e73248 47 return this->m_is_observing;
ansond 0:1f1f55e73248 48 }
ansond 0:1f1f55e73248 49
ansond 0:1f1f55e73248 50 // set our observation state
ansond 0:1f1f55e73248 51 void ResourceObserver::setObserving(bool observing) {
ansond 0:1f1f55e73248 52 this->m_is_observing = observing;
ansond 0:1f1f55e73248 53 }
ansond 0:1f1f55e73248 54
ansond 0:1f1f55e73248 55 // get our sleep time
ansond 0:1f1f55e73248 56 int ResourceObserver::getSleepTime() {
ansond 0:1f1f55e73248 57 return this->m_sleep_time;
ansond 0:1f1f55e73248 58 }