added max-age and content-format
Fork of mbedConnectorInterface by
api/ThreadedResourceObserver.h@52:822611156e35, 2015-04-14 (annotated)
- Committer:
- michaeljkoster
- Date:
- Tue Apr 14 04:00:01 2015 +0000
- Revision:
- 52:822611156e35
- Parent:
- 43:769d491a48c1
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 ThreadedResourceObserver.h |
ansond | 30:113c2a1d8db2 | 3 | * @brief mbed CoAP DynamicResource Thread-based observer (header) |
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 | #ifndef __THREADED_RESOURCE_OBSERVER_H__ |
ansond | 30:113c2a1d8db2 | 24 | #define __THREADED_RESOURCE_OBSERVER_H__ |
ansond | 30:113c2a1d8db2 | 25 | |
ansond | 31:bacc63106754 | 26 | // mbed support |
ansond | 30:113c2a1d8db2 | 27 | #include "mbed.h" |
ansond | 31:bacc63106754 | 28 | |
ansond | 43:769d491a48c1 | 29 | // switch for proper resource observer selection (from mbedEndpointNetwork) |
ansond | 43:769d491a48c1 | 30 | #include "configuration.h" |
ansond | 43:769d491a48c1 | 31 | |
ansond | 35:f12e61aaf004 | 32 | // mbedConnectorInterface configuration |
ansond | 35:f12e61aaf004 | 33 | #include "mbedConnectorInterface.h" |
ansond | 35:f12e61aaf004 | 34 | |
ansond | 31:bacc63106754 | 35 | // Thread support |
ansond | 31:bacc63106754 | 36 | #ifdef CONNECTOR_USING_THREADS |
ansond | 31:bacc63106754 | 37 | #include "rtos.h" |
ansond | 31:bacc63106754 | 38 | #endif |
ansond | 30:113c2a1d8db2 | 39 | |
ansond | 30:113c2a1d8db2 | 40 | // Base class support |
ansond | 30:113c2a1d8db2 | 41 | #include "ResourceObserver.h" |
ansond | 30:113c2a1d8db2 | 42 | |
ansond | 30:113c2a1d8db2 | 43 | class ThreadedResourceObserver : public ResourceObserver { |
ansond | 30:113c2a1d8db2 | 44 | public: |
ansond | 30:113c2a1d8db2 | 45 | /** |
ansond | 30:113c2a1d8db2 | 46 | Default Constructor |
ansond | 30:113c2a1d8db2 | 47 | @param resource input the resource to observe |
ansond | 31:bacc63106754 | 48 | @param sleep_time input the time for the observation thread to sleep (in ms) |
ansond | 30:113c2a1d8db2 | 49 | */ |
ansond | 42:20c375e74e8e | 50 | ThreadedResourceObserver(DynamicResource *resource,int sleep_time = NSP_DEFAULT_OBS_PERIOD); |
ansond | 30:113c2a1d8db2 | 51 | |
ansond | 30:113c2a1d8db2 | 52 | /** |
ansond | 30:113c2a1d8db2 | 53 | Destructor |
ansond | 30:113c2a1d8db2 | 54 | */ |
ansond | 30:113c2a1d8db2 | 55 | virtual ~ThreadedResourceObserver(); |
ansond | 30:113c2a1d8db2 | 56 | |
ansond | 30:113c2a1d8db2 | 57 | /** |
ansond | 30:113c2a1d8db2 | 58 | begin the observation |
ansond | 30:113c2a1d8db2 | 59 | */ |
ansond | 30:113c2a1d8db2 | 60 | virtual void beginObservation(); |
ansond | 30:113c2a1d8db2 | 61 | |
ansond | 30:113c2a1d8db2 | 62 | /** |
ansond | 31:bacc63106754 | 63 | stop the observation |
ansond | 31:bacc63106754 | 64 | */ |
ansond | 31:bacc63106754 | 65 | virtual void stopObservation(); |
ansond | 31:bacc63106754 | 66 | |
ansond | 31:bacc63106754 | 67 | /** |
ansond | 30:113c2a1d8db2 | 68 | thread invoke function (static) |
ansond | 30:113c2a1d8db2 | 69 | */ |
ansond | 31:bacc63106754 | 70 | static void _observation_notifier(void const *instance); |
ansond | 30:113c2a1d8db2 | 71 | |
ansond | 30:113c2a1d8db2 | 72 | private: |
ansond | 31:bacc63106754 | 73 | #ifdef CONNECTOR_USING_THREADS |
ansond | 30:113c2a1d8db2 | 74 | Thread m_observation_thread; |
ansond | 31:bacc63106754 | 75 | #endif |
ansond | 30:113c2a1d8db2 | 76 | }; |
ansond | 30:113c2a1d8db2 | 77 | |
ansond | 30:113c2a1d8db2 | 78 | #endif // __THREADED_RESOURCE_OBSERVER_H__ |