observe updates

Fork of mbedConnectorInterface by Doug Anson

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ResourceObserver.h Source File

ResourceObserver.h

Go to the documentation of this file.
00001 /**
00002  * @file    ResourceObserver.h
00003  * @brief   mbed CoAP DynamicResource observer (header)
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 #ifndef __RESOURCE_OBSERVER_H__
00024 #define __RESOURCE_OBSERVER_H__
00025 
00026 // DynamicResource
00027 #include "DynamicResource.h"
00028 
00029 class ResourceObserver {
00030     public:
00031         /**
00032         Default Constructor
00033         @param resource input the resource to observe
00034         @param sleep_time input the amount of time to sleep between observations
00035         */
00036         ResourceObserver(DynamicResource *resource,int sleep_time);
00037         
00038         /**
00039         Copy Constructor
00040         */
00041         ResourceObserver(const ResourceObserver &observer);
00042         
00043         /**
00044         Destructor
00045         */
00046         virtual ~ResourceObserver();
00047         
00048         /**
00049         begin the observation (ABSTRACT)
00050         */
00051         virtual void beginObservation() = 0;
00052         
00053         /**
00054         stop the observation (ABSTRACT)
00055         */
00056         virtual void stopObservation() = 0;
00057     
00058         /** 
00059         we are observing?
00060         */
00061         bool isObserving();
00062         
00063         /**
00064         get our sleep time
00065         */
00066         int getSleepTime();
00067         
00068     protected:
00069         DynamicResource *getResource();
00070         void             setObserving(bool observing);
00071         
00072     private:
00073         DynamicResource *m_resource;
00074         bool             m_is_observing;
00075         int              m_sleep_time;
00076 };
00077 
00078 #endif // __RESOURCE_OBSERVER_H__