observe updates

Fork of mbedConnectorInterface by Doug Anson

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ResourceObserver.cpp Source File

ResourceObserver.cpp

Go to the documentation of this file.
00001 /**
00002  * @file    ResourceObserver.cpp
00003  * @brief   mbed CoAP DynamicResource observer (implementation)
00004  * @author  Doug Anson/Chris Paola
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2014
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022  
00023  #include "ResourceObserver.h"
00024  
00025  // constructor
00026  ResourceObserver::ResourceObserver(DynamicResource *resource,int sleep_time) : m_is_observing(false), m_sleep_time(sleep_time) {
00027      this->m_resource = resource;
00028      if (resource != NULL) resource->setObserver(this);
00029  }
00030  
00031  // copy constructor
00032  ResourceObserver::ResourceObserver(const ResourceObserver &observer) {
00033      this->m_resource = observer.m_resource;
00034  }
00035  
00036  // destructor
00037  ResourceObserver::~ResourceObserver() {
00038  }
00039  
00040  // get our resource
00041  DynamicResource *ResourceObserver::getResource() {
00042      return this->m_resource;
00043  }
00044  
00045  // we are observing?
00046  bool ResourceObserver::isObserving() {
00047      return this->m_is_observing;
00048  }
00049  
00050  // set our observation state
00051  void ResourceObserver::setObserving(bool observing) {
00052      this->m_is_observing = observing;
00053  }
00054  
00055  // get our sleep time
00056  int ResourceObserver::getSleepTime() {
00057      return this->m_sleep_time;
00058  }