mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
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!
mbed-connector-interface/ResourceObserver.h@127:b4a661ff6fb9, 2017-09-26 (annotated)
- Committer:
- ansond
- Date:
- Tue Sep 26 16:01:31 2017 +0000
- Revision:
- 127:b4a661ff6fb9
- Parent:
- 54:dfee8691c83a
minor re-ordering of FCC init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 33:1d0b855df5a5 | 1 | /** |
ansond | 33:1d0b855df5a5 | 2 | * @file ResourceObserver.h |
ansond | 33:1d0b855df5a5 | 3 | * @brief mbed CoAP DynamicResource observer (header) |
ansond | 33:1d0b855df5a5 | 4 | * @author Doug Anson/Chris Paola |
ansond | 33:1d0b855df5a5 | 5 | * @version 1.0 |
ansond | 33:1d0b855df5a5 | 6 | * @see |
ansond | 33:1d0b855df5a5 | 7 | * |
ansond | 33:1d0b855df5a5 | 8 | * Copyright (c) 2014 |
ansond | 33:1d0b855df5a5 | 9 | * |
ansond | 33:1d0b855df5a5 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 33:1d0b855df5a5 | 11 | * you may not use this file except in compliance with the License. |
ansond | 33:1d0b855df5a5 | 12 | * You may obtain a copy of the License at |
ansond | 33:1d0b855df5a5 | 13 | * |
ansond | 33:1d0b855df5a5 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 33:1d0b855df5a5 | 15 | * |
ansond | 33:1d0b855df5a5 | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 33:1d0b855df5a5 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 33:1d0b855df5a5 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 33:1d0b855df5a5 | 19 | * See the License for the specific language governing permissions and |
ansond | 33:1d0b855df5a5 | 20 | * limitations under the License. |
ansond | 33:1d0b855df5a5 | 21 | */ |
ansond | 33:1d0b855df5a5 | 22 | |
ansond | 33:1d0b855df5a5 | 23 | #ifndef __RESOURCE_OBSERVER_H__ |
ansond | 33:1d0b855df5a5 | 24 | #define __RESOURCE_OBSERVER_H__ |
ansond | 33:1d0b855df5a5 | 25 | |
ansond | 33:1d0b855df5a5 | 26 | // DynamicResource |
ansond | 33:1d0b855df5a5 | 27 | #include "mbed-connector-interface/DynamicResource.h" |
ansond | 33:1d0b855df5a5 | 28 | |
ansond | 33:1d0b855df5a5 | 29 | class ResourceObserver { |
ansond | 33:1d0b855df5a5 | 30 | public: |
ansond | 33:1d0b855df5a5 | 31 | /** |
ansond | 33:1d0b855df5a5 | 32 | Default Constructor |
ansond | 33:1d0b855df5a5 | 33 | @param resource input the resource to observe |
ansond | 33:1d0b855df5a5 | 34 | @param sleep_time input the amount of time to sleep between observations |
ansond | 33:1d0b855df5a5 | 35 | */ |
ansond | 33:1d0b855df5a5 | 36 | ResourceObserver(DynamicResource *resource,int sleep_time); |
ansond | 33:1d0b855df5a5 | 37 | |
ansond | 33:1d0b855df5a5 | 38 | /** |
ansond | 33:1d0b855df5a5 | 39 | Copy Constructor |
ansond | 33:1d0b855df5a5 | 40 | */ |
ansond | 33:1d0b855df5a5 | 41 | ResourceObserver(const ResourceObserver &observer); |
ansond | 33:1d0b855df5a5 | 42 | |
ansond | 33:1d0b855df5a5 | 43 | /** |
ansond | 33:1d0b855df5a5 | 44 | Destructor |
ansond | 33:1d0b855df5a5 | 45 | */ |
ansond | 33:1d0b855df5a5 | 46 | virtual ~ResourceObserver(); |
ansond | 33:1d0b855df5a5 | 47 | |
ansond | 33:1d0b855df5a5 | 48 | /** |
ansond | 33:1d0b855df5a5 | 49 | begin the observation (ABSTRACT) |
ansond | 33:1d0b855df5a5 | 50 | */ |
ansond | 33:1d0b855df5a5 | 51 | virtual void beginObservation() = 0; |
ansond | 33:1d0b855df5a5 | 52 | |
ansond | 33:1d0b855df5a5 | 53 | /** |
ansond | 33:1d0b855df5a5 | 54 | stop the observation (ABSTRACT) |
ansond | 33:1d0b855df5a5 | 55 | */ |
ansond | 33:1d0b855df5a5 | 56 | virtual void stopObservation() = 0; |
ansond | 33:1d0b855df5a5 | 57 | |
ansond | 33:1d0b855df5a5 | 58 | /** |
ansond | 33:1d0b855df5a5 | 59 | we are observing? |
ansond | 33:1d0b855df5a5 | 60 | */ |
ansond | 33:1d0b855df5a5 | 61 | bool isObserving(); |
ansond | 33:1d0b855df5a5 | 62 | |
ansond | 33:1d0b855df5a5 | 63 | /** |
ansond | 33:1d0b855df5a5 | 64 | get our sleep time |
ansond | 33:1d0b855df5a5 | 65 | */ |
ansond | 33:1d0b855df5a5 | 66 | int getSleepTime(); |
ansond | 54:dfee8691c83a | 67 | |
ansond | 54:dfee8691c83a | 68 | /** |
ansond | 54:dfee8691c83a | 69 | halt the underlying observer mechanism |
ansond | 54:dfee8691c83a | 70 | */ |
ansond | 54:dfee8691c83a | 71 | virtual void halt(); |
ansond | 33:1d0b855df5a5 | 72 | |
ansond | 33:1d0b855df5a5 | 73 | protected: |
ansond | 33:1d0b855df5a5 | 74 | DynamicResource *getResource(); |
ansond | 33:1d0b855df5a5 | 75 | void setObserving(bool observing); |
ansond | 54:dfee8691c83a | 76 | Logger *logger(); |
ansond | 33:1d0b855df5a5 | 77 | |
ansond | 33:1d0b855df5a5 | 78 | private: |
ansond | 33:1d0b855df5a5 | 79 | DynamicResource *m_resource; |
ansond | 33:1d0b855df5a5 | 80 | bool m_is_observing; |
ansond | 33:1d0b855df5a5 | 81 | int m_sleep_time; |
ansond | 33:1d0b855df5a5 | 82 | }; |
ansond | 33:1d0b855df5a5 | 83 | |
ansond | 0:1f1f55e73248 | 84 | #endif // __RESOURCE_OBSERVER_H__ |