Doug Anson / mbedConnectorInterface

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Embed: (wiki syntax)

« Back to documentation index

DynamicResource Class Reference

DynamicResource Class Reference

DynamicResource class. More...

#include <DynamicResource.h>

Inherits Resource< string >.

Public Member Functions

 DynamicResource (const Logger *logger, const char *name, const char *res_type, uint8_t res_mask, const bool observable=false)
 Default constructor (char strings)
 DynamicResource (const Logger *logger, const char *name, const char *res_type, const string value, uint8_t res_mask, const bool observable=false)
 Default constructor (char strings)
 DynamicResource (const Logger *logger, const string name, const string res_type, const string value, uint8_t res_mask, const bool observable=false)
 constructor with string buffer for name
 DynamicResource (const DynamicResource &resource)
 Copy constructor.
virtual ~DynamicResource ()
 Destructor.
virtual void bind (void *p)
 Bind resource to endpoint.
uint8_t process (sn_coap_hdr_s *received_coap_ptr, sn_nsdl_addr_s *address, sn_proto_info_s *proto)
 Process the CoAP message.
virtual string get ()=0
 Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET)
virtual void put (const string value)
 Resource value setter (PUT) (OPTIONAL: defaulted noop if not derived.
virtual void post (const string value)
 Resource value setter (POST) (OPTIONAL: defaulted noop if not derived.
virtual void del (const string value)
 Resource value deleter (OPTIONAL: defaulted noop if not derived.
int notify (const string data)
 Send notification of new data.
bool isObservable ()
 Determine whether this dynamic resource is observable or not.
void setObserver (void *observer)
 Set the observer pointer.
void setContentFormat (uint8_t content_format)
 Set the content format for responses.
void setMaxAge (uint8_t maxage)
 Set the max-age for cache control of responses in a proxy cache.
void setDataWrapper (DataWrapper *data_wrapper)
 Set the data wrapper.
virtual void observe ()
 observe the resource (default)
virtual void observe (bool do_notify)
 observe the resource (controlled observing)
string getName ()
 Get the resource name.
string getValue ()
 Get the resource value.
void setName (const string name)
 Set the resource name.
void setValue (const stringvalue)
 Set the resource value.
void setOptions (const void *options)
 set the options

Detailed Description

DynamicResource class.

Definition at line 37 of file DynamicResource.h.


Constructor & Destructor Documentation

DynamicResource ( const Logger logger,
const char *  name,
const char *  res_type,
uint8_t  res_mask,
const bool  observable = false 
)

Default constructor (char strings)

Parameters:
loggerinput logger instance for this resource
nameinput the Resource URI/Name
res_typeinput type for the Resource
res_maskinput the resource enablement mask (GET, PUT, etc...)
observableinput the resource is Observable (default: FALSE)

Definition at line 45 of file DynamicResource.cpp.

DynamicResource ( const Logger logger,
const char *  name,
const char *  res_type,
const string  value,
uint8_t  res_mask,
const bool  observable = false 
)

Default constructor (char strings)

Parameters:
loggerinput logger instance for this resource
nameinput the Resource URI/Name
res_typeinput type for the Resource
valueinput initial value for the Resource
res_maskinput the resource enablement mask (GET, PUT, etc...)
observableinput the resource is Observable (default: FALSE)

Definition at line 60 of file DynamicResource.cpp.

DynamicResource ( const Logger logger,
const string  name,
const string  res_type,
const string  value,
uint8_t  res_mask,
const bool  observable = false 
)

constructor with string buffer for name

Parameters:
loggerinput logger instance for this resource
nameinput the Resource URI/Name
res_typeinput type for the Resource
valueinput initial value for the Resource
res_maskinput the resource enablement mask (GET, PUT, etc...)
observableinput the resource is Observable (default: FALSE)

Definition at line 75 of file DynamicResource.cpp.

DynamicResource ( const DynamicResource resource )

Copy constructor.

Parameters:
resourceinput the DynamicResource that is to be deep copied

Definition at line 90 of file DynamicResource.cpp.

~DynamicResource (  ) [virtual]

Destructor.

Definition at line 105 of file DynamicResource.cpp.


Member Function Documentation

void bind ( void *  p ) [virtual]

Bind resource to endpoint.

Parameters:
pinput pointer to the endpoint resources necessary for binding

Implements Resource< string >.

Definition at line 111 of file DynamicResource.cpp.

void del ( const string  value ) [virtual]

Resource value deleter (OPTIONAL: defaulted noop if not derived.

Binders MAY implement DELETE if needed)

Parameters:
stringvalue of the resource

Definition at line 399 of file DynamicResource.cpp.

virtual string get (  ) [pure virtual]

Resource value getter (REQUIRED: must be implemented in derived class as all Binders MUST support and implement GET)

Returns:
string value of the resource
string getName (  ) [inherited]

Get the resource name.

Returns:
the name of the resource

Definition at line 72 of file Resource.h.

string getValue (  ) [inherited]

Get the resource value.

Returns:
the value of the resource

Definition at line 80 of file Resource.h.

bool isObservable (  )

Determine whether this dynamic resource is observable or not.

Returns:
true - is observable, false - otherwise

Definition at line 133 of file DynamicResource.h.

int notify ( const string  data )

Send notification of new data.

Parameters:
datainput the new data to update
Returns:
1 - success, 0 - failure

Definition at line 332 of file DynamicResource.cpp.

void observe (  ) [virtual]

observe the resource (default)

Definition at line 406 of file DynamicResource.cpp.

void observe ( bool  do_notify ) [virtual]

observe the resource (controlled observing)

Definition at line 411 of file DynamicResource.cpp.

void post ( const string  value ) [virtual]

Resource value setter (POST) (OPTIONAL: defaulted noop if not derived.

Binders MAY implement POST if needed)

Parameters:
stringvalue of the resource

Definition at line 392 of file DynamicResource.cpp.

uint8_t process ( sn_coap_hdr_s *  received_coap_ptr,
sn_nsdl_addr_s *  address,
sn_proto_info_s *  proto 
)

Process the CoAP message.

Parameters:
received_coap_ptrinput the received coap pointer
addressinput the NSDL address pointer
protoinput the NSDL protocol pointer
Returns:
0 - success, 1 - failure

Definition at line 131 of file DynamicResource.cpp.

void put ( const string  value ) [virtual]

Resource value setter (PUT) (OPTIONAL: defaulted noop if not derived.

Binders MAY implement PUT if needed)

Parameters:
stringvalue of the resource

Definition at line 385 of file DynamicResource.cpp.

void setContentFormat ( uint8_t  content_format )

Set the content format for responses.

Parameters:
content_formatshort integer CoAP content-format ID

Definition at line 430 of file DynamicResource.cpp.

void setDataWrapper ( DataWrapper *  data_wrapper )

Set the data wrapper.

Parameters:
data_wrapperinput the data wrapper instance

Definition at line 157 of file DynamicResource.h.

void setMaxAge ( uint8_t  maxage )

Set the max-age for cache control of responses in a proxy cache.

Parameters:
maxageshort integer CoAP max-age in seconds

Definition at line 435 of file DynamicResource.cpp.

void setName ( const string  name ) [inherited]

Set the resource name.

Parameters:
nameinput the resource name

Definition at line 88 of file Resource.h.

void setObserver ( void *  observer )

Set the observer pointer.

Parameters:
observerinput the pointer to the ResourceObserver observing this resource

Definition at line 425 of file DynamicResource.cpp.

void setOptions ( const void *  options ) [inherited]

set the options

Definition at line 113 of file Resource.h.

void setValue ( const string  value ) [inherited]

Set the resource value.

Parameters:
valueinput the resource value

Definition at line 96 of file Resource.h.