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