Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mresourceinstance.h Source File

m2mresourceinstance.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2015 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef M2M_RESOURCE_INSTANCE_H
00017 #define M2M_RESOURCE_INSTANCE_H
00018 
00019 #include "mbed-client/m2mresourcebase.h"
00020 
00021 
00022 /*! \file m2mresourceinstance.h
00023  *  \brief M2MResourceInstance.
00024  *  This class is the base class for mbed Client Resources. All defined
00025  *  LWM2M resource models can be created based on it.
00026  */
00027 class M2MBlockMessage;
00028 
00029 
00030 class M2MResource;
00031 
00032 class M2MResourceInstance : public M2MResourceBase {
00033 
00034 friend class M2MObjectInstance;
00035 friend class M2MResource;
00036 
00037 private: // Constructor and destructor are private
00038          // which means that these objects can be created or
00039          // deleted only through a function provided by the M2MObjectInstance.
00040 
00041     M2MResourceInstance(M2MResource &parent,
00042                         const lwm2m_parameters_s* s,
00043                         M2MBase::DataType type);
00044     /**
00045      * \brief A constructor for creating a resource.
00046      * \param resource_name The name of the resource.
00047      * \param resource_type The type of the resource.
00048      * \param type The resource data type of the object.
00049      * \param object_name Object name where resource exists.
00050      * \param path Path of the object like 3/0/1
00051      * \param external_blockwise_store If true CoAP blocks are passed to application through callbacks
00052      *        otherwise handled in mbed-client-c.
00053      */
00054     M2MResourceInstance(M2MResource &parent,
00055                         const String &resource_name,
00056                         M2MBase::Mode mode,
00057                         const String &resource_type,
00058                         M2MBase::DataType type,
00059                         char* path,
00060                         bool external_blockwise_store,
00061                         bool multiple_instance);
00062 
00063     /**
00064      * \brief A Constructor for creating a resource.
00065      * \param resource_name The name of the resource.
00066      * \param resource_type The type of the resource.
00067      * \param type The resource data type of the object.
00068      * \param value The value pointer of the object.
00069      * \param value_length The length of the value pointer.
00070      * \param value_length The length of the value pointer.
00071      * \param object_name Object name where resource exists.
00072      * \param path Path of the object like 3/0/1
00073      * \param external_blockwise_store If true CoAP blocks are passed to application through callbacks
00074      *        otherwise handled in mbed-client-c.
00075      */
00076     M2MResourceInstance(M2MResource &parent,
00077                         const String &resource_name,
00078                         M2MBase::Mode mode,
00079                         const String &resource_type,
00080                         M2MBase::DataType type,
00081                         const uint8_t *value,
00082                         const uint8_t value_length,
00083                         char* path,
00084                         bool external_blockwise_store,
00085                         bool multiple_instance);
00086 
00087     // Prevents the use of default constructor.
00088     M2MResourceInstance();
00089 
00090     // Prevents the use of assignment operator.
00091     M2MResourceInstance& operator=( const M2MResourceInstance& /*other*/ );
00092 
00093     // Prevents the use of copy constructor
00094     M2MResourceInstance( const M2MResourceInstance& /*other*/ );
00095 
00096     /**
00097      * Destructor
00098      */
00099     virtual ~M2MResourceInstance();
00100 
00101 protected:
00102     /**
00103      * \brief Returns the owner object. Can return NULL if the object has no parent.
00104      */
00105     virtual M2MBase *get_parent() const;
00106 
00107 public:
00108 
00109     /**
00110      * \brief Returns the Observation Handler object.
00111      * \return M2MObservationHandler object.
00112     */
00113     virtual M2MObservationHandler* observation_handler() const;
00114 
00115     /**
00116      * \brief Sets the observation handler
00117      * \param handler Observation handler
00118     */
00119     virtual void set_observation_handler(M2MObservationHandler *handler);
00120 
00121     /**
00122      * \brief Parses the received query for a notification
00123      * attribute.
00124      * \return True if required attributes are present, else false.
00125      */
00126     virtual bool handle_observation_attribute(const char *query);
00127 
00128 
00129     /**
00130      * \brief Returns the instance ID of the object where the resource exists.
00131      * \return Object instance ID.
00132     */
00133     virtual uint16_t object_instance_id() const;
00134 
00135     /**
00136      * \brief Returns the name of the object where the resource exists.
00137      * \return Object name.
00138     */
00139     virtual const char* object_name() const;
00140 
00141     /**
00142      * \brief Get reference to the resource owning this resource instance.
00143      * \return parent resource
00144      */
00145     virtual M2MResource& get_parent_resource() const;
00146 
00147 private:
00148 
00149     // Parent resource which owns this resource instance
00150     M2MResource &_parent_resource;
00151 
00152     friend class Test_M2MResourceInstance;
00153     friend class Test_M2MResource;
00154     friend class Test_M2MObjectInstance;
00155     friend class Test_M2MObject;
00156     friend class Test_M2MDevice;
00157     friend class Test_M2MSecurity;
00158     friend class Test_M2MServer;
00159     friend class Test_M2MNsdlInterface;
00160     friend class Test_M2MFirmware;
00161     friend class Test_M2MTLVSerializer;
00162     friend class Test_M2MTLVDeserializer;
00163 };
00164 
00165 #endif // M2M_RESOURCE_INSTANCE_H