added max-age and content-format
Fork of mbedConnectorInterface by
api/ResourceObserver.h@31:bacc63106754, 2015-04-08 (annotated)
- Committer:
- ansond
- Date:
- Wed Apr 08 15:49:56 2015 +0000
- Revision:
- 31:bacc63106754
- Parent:
- 30:113c2a1d8db2
updates for tasklet observing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 30:113c2a1d8db2 | 1 | /** |
ansond | 30:113c2a1d8db2 | 2 | * @file ResourceObserver.h |
ansond | 30:113c2a1d8db2 | 3 | * @brief mbed CoAP DynamicResource 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 __RESOURCE_OBSERVER_H__ |
ansond | 30:113c2a1d8db2 | 24 | #define __RESOURCE_OBSERVER_H__ |
ansond | 30:113c2a1d8db2 | 25 | |
ansond | 30:113c2a1d8db2 | 26 | // DynamicResource |
ansond | 30:113c2a1d8db2 | 27 | #include "DynamicResource.h" |
ansond | 30:113c2a1d8db2 | 28 | |
ansond | 30:113c2a1d8db2 | 29 | class ResourceObserver { |
ansond | 30:113c2a1d8db2 | 30 | public: |
ansond | 30:113c2a1d8db2 | 31 | /** |
ansond | 30:113c2a1d8db2 | 32 | Default Constructor |
ansond | 30:113c2a1d8db2 | 33 | @param resource input the resource to observe |
ansond | 31:bacc63106754 | 34 | @param sleep_time input the amount of time to sleep between observations |
ansond | 30:113c2a1d8db2 | 35 | */ |
ansond | 31:bacc63106754 | 36 | ResourceObserver(DynamicResource *resource,int sleep_time); |
ansond | 30:113c2a1d8db2 | 37 | |
ansond | 30:113c2a1d8db2 | 38 | /** |
ansond | 30:113c2a1d8db2 | 39 | Copy Constructor |
ansond | 30:113c2a1d8db2 | 40 | */ |
ansond | 30:113c2a1d8db2 | 41 | ResourceObserver(const ResourceObserver &observer); |
ansond | 30:113c2a1d8db2 | 42 | |
ansond | 30:113c2a1d8db2 | 43 | /** |
ansond | 30:113c2a1d8db2 | 44 | Destructor |
ansond | 30:113c2a1d8db2 | 45 | */ |
ansond | 30:113c2a1d8db2 | 46 | virtual ~ResourceObserver(); |
ansond | 30:113c2a1d8db2 | 47 | |
ansond | 30:113c2a1d8db2 | 48 | /** |
ansond | 30:113c2a1d8db2 | 49 | begin the observation (ABSTRACT) |
ansond | 30:113c2a1d8db2 | 50 | */ |
ansond | 30:113c2a1d8db2 | 51 | virtual void beginObservation() = 0; |
ansond | 31:bacc63106754 | 52 | |
ansond | 31:bacc63106754 | 53 | /** |
ansond | 31:bacc63106754 | 54 | stop the observation (ABSTRACT) |
ansond | 31:bacc63106754 | 55 | */ |
ansond | 31:bacc63106754 | 56 | virtual void stopObservation() = 0; |
ansond | 30:113c2a1d8db2 | 57 | |
ansond | 31:bacc63106754 | 58 | /** |
ansond | 31:bacc63106754 | 59 | we are observing? |
ansond | 31:bacc63106754 | 60 | */ |
ansond | 31:bacc63106754 | 61 | bool isObserving(); |
ansond | 31:bacc63106754 | 62 | |
ansond | 31:bacc63106754 | 63 | /** |
ansond | 31:bacc63106754 | 64 | get our sleep time |
ansond | 31:bacc63106754 | 65 | */ |
ansond | 31:bacc63106754 | 66 | int getSleepTime(); |
ansond | 31:bacc63106754 | 67 | |
ansond | 30:113c2a1d8db2 | 68 | protected: |
ansond | 31:bacc63106754 | 69 | DynamicResource *getResource(); |
ansond | 31:bacc63106754 | 70 | void setObserving(bool observing); |
ansond | 31:bacc63106754 | 71 | |
ansond | 31:bacc63106754 | 72 | private: |
ansond | 30:113c2a1d8db2 | 73 | DynamicResource *m_resource; |
ansond | 31:bacc63106754 | 74 | bool m_is_observing; |
ansond | 31:bacc63106754 | 75 | int m_sleep_time; |
ansond | 30:113c2a1d8db2 | 76 | }; |
ansond | 30:113c2a1d8db2 | 77 | |
ansond | 30:113c2a1d8db2 | 78 | #endif // __RESOURCE_OBSERVER_H__ |