custom for >5 resources

Fork of mbedConnectorInterface by Doug Anson

Revision:
2:853f9ecc12df
Parent:
0:b438482ebbfc
Child:
15:8ada80242804
diff -r cabdd0350707 -r 853f9ecc12df api/OptionsBuilder.cpp
--- a/api/OptionsBuilder.cpp	Tue Jan 27 22:52:25 2015 +0000
+++ b/api/OptionsBuilder.cpp	Tue Jan 27 23:41:34 2015 +0000
@@ -3,7 +3,7 @@
  * @brief   mbed CoAP OptionsBuilder class implementation
  * @author  Doug Anson/Chris Paola
  * @version 1.0
- * @see     
+ * @see
  *
  * Copyright (c) 2014
  *
@@ -19,92 +19,138 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
- #include "OptionsBuilder.h"
- 
- // external included configuration file for the endpoint...
- #include "configuration.h"
- 
- // Connector namespace
- namespace Connector {
-     // Constructor
-     OptionsBuilder::OptionsBuilder() {
-         this->m_lifetime         = NSP_LIFE_TIME;
-         this->m_domain           = NSP_DOMAIN;
-         this->m_endpoint_type    = NSP_ENDPOINT_TYPE;
-         this->m_node_name        = NODE_NAME;
-         this->m_channel_list     = NODE_CHANNEL_LIST;
-         this->m_rd_update_period = NSP_RD_UPDATE_PERIOD;
-         this->m_nsp_port         = NSP_COAP_UDP_PORT; 
-         
-         memset(this->m_nsp_address,0,NSP_IP_ADDRESS_LENGTH);
-         memset(this->m_mac_address,0,NODE_MAC_ADDRESS_LENGTH);
-         this->m_static_resources.clear();
-         this->m_dynamic_resources.clear();
-     }
-     
-     // Copy Constructor
-     OptionsBuilder::OptionsBuilder(const OptionsBuilder &ob) {
-         this->m_lifetime = ob.m_lifetime;
-         this->m_domain = ob.m_domain;
-         this->m_endpoint_type = ob.m_endpoint_type;
-         this->m_static_resources = ob.m_static_resources;
-         this->m_dynamic_resources = ob.m_dynamic_resources;
-     }
-     
-     // Destructor
-     OptionsBuilder::~OptionsBuilder() {
-         this->m_static_resources.clear();
-         this->m_dynamic_resources.clear();
-     }
-     
-     // set lifetime
-     OptionsBuilder &OptionsBuilder::setLifetime(const char *lifetime) { this->m_lifetime = (char *)lifetime; return *this; }
-     
-     // set domain
-     OptionsBuilder &OptionsBuilder::setDomain(const char *domain) { this->m_domain = string(domain); return *this; }
-     
-     // set endpoint nodename
-     OptionsBuilder &OptionsBuilder::setEndpointNodename(const char *node_name) { this->m_node_name = string(node_name); return *this; }
-    
-     // set lifetime
-     OptionsBuilder &OptionsBuilder::setEndpointType(const char *endpoint_type) { this->m_endpoint_type = string(endpoint_type); return *this; }
-    
-     // set NSP port number
-     OptionsBuilder &OptionsBuilder::setNSPPortNumber(const int port_num) { this->m_nsp_port = port_num; return *this; }
-    
-     // set low level radio channel list
-     OptionsBuilder &OptionsBuilder::setRadioChannelList(const uint32_t channel_list) { this->m_channel_list = channel_list; return *this; }
-    
-     // set NSP read update period
-     OptionsBuilder &OptionsBuilder::setReadUpdatePeriod(const int rd_update_period) { this->m_rd_update_period = rd_update_period; return *this; }
-     
-     // set NSP address
-     OptionsBuilder &OptionsBuilder::setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length) {
-        if (nsp_address != NULL && nsp_address_length > 0) { 
-            int length = nsp_address_length;
-            if (length > NSP_IP_ADDRESS_LENGTH) length = NSP_IP_ADDRESS_LENGTH;
-            for(int i=0;i<length;++i) this->m_nsp_address[i] = nsp_address[i];
-        }
-        return *this;
-     }
-    
-     // set MAC address
-     OptionsBuilder &OptionsBuilder::setMACAddress(const uint8_t *mac_address,const int mac_address_length) { 
-        if (mac_address != NULL && mac_address_length > 0) { 
-            int length = mac_address_length;
-            if (length > NODE_MAC_ADDRESS_LENGTH) length = NODE_MAC_ADDRESS_LENGTH;
-            for(int i=0;i<length;++i) this->m_mac_address[i] = mac_address[i];
-        }
-        return *this; 
-     }
-     
-     // add static resource
-     OptionsBuilder &OptionsBuilder::addResource(const StaticResource *resource) { this->m_static_resources.push_back((StaticResource *)resource); return *this; }
-     
-     // add dynamic resource
-     OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource) { this->m_dynamic_resources.push_back((DynamicResource *)resource); return *this; }
-     
-     // build out our immutable self
-     Options *OptionsBuilder::build() { return (Options *)this; }
- }
\ No newline at end of file
+
+#include "OptionsBuilder.h"
+
+// external included configuration file for the endpoint...
+#include "configuration.h"
+
+// Connector namespace
+namespace Connector {
+
+// Constructor
+OptionsBuilder::OptionsBuilder()
+{
+    this->m_lifetime         = NSP_LIFE_TIME;
+    this->m_domain           = NSP_DOMAIN;
+    this->m_endpoint_type    = NSP_ENDPOINT_TYPE;
+    this->m_node_name        = NODE_NAME;
+    this->m_channel_list     = NODE_CHANNEL_LIST;
+    this->m_rd_update_period = NSP_RD_UPDATE_PERIOD;
+    this->m_nsp_port         = NSP_COAP_UDP_PORT;
+
+    memset(this->m_nsp_address,0,NSP_IP_ADDRESS_LENGTH);
+    memset(this->m_mac_address,0,NODE_MAC_ADDRESS_LENGTH);
+    this->m_static_resources.clear();
+    this->m_dynamic_resources.clear();
+}
+
+// Copy Constructor
+OptionsBuilder::OptionsBuilder(const OptionsBuilder &ob)
+{
+    this->m_lifetime = ob.m_lifetime;
+    this->m_domain = ob.m_domain;
+    this->m_endpoint_type = ob.m_endpoint_type;
+    this->m_static_resources = ob.m_static_resources;
+    this->m_dynamic_resources = ob.m_dynamic_resources;
+}
+
+// Destructor
+OptionsBuilder::~OptionsBuilder()
+{
+    this->m_static_resources.clear();
+    this->m_dynamic_resources.clear();
+}
+
+// set lifetime
+OptionsBuilder &OptionsBuilder::setLifetime(const char *lifetime)
+{
+    this->m_lifetime = (char *)lifetime;
+    return *this;
+}
+
+// set domain
+OptionsBuilder &OptionsBuilder::setDomain(const char *domain)
+{
+    this->m_domain = string(domain);
+    return *this;
+}
+
+// set endpoint nodename
+OptionsBuilder &OptionsBuilder::setEndpointNodename(const char *node_name)
+{
+    this->m_node_name = string(node_name);
+    return *this;
+}
+
+// set lifetime
+OptionsBuilder &OptionsBuilder::setEndpointType(const char *endpoint_type)
+{
+    this->m_endpoint_type = string(endpoint_type);
+    return *this;
+}
+
+// set NSP port number
+OptionsBuilder &OptionsBuilder::setNSPPortNumber(const int port_num)
+{
+    this->m_nsp_port = port_num;
+    return *this;
+}
+
+// set low level radio channel list
+OptionsBuilder &OptionsBuilder::setRadioChannelList(const uint32_t channel_list)
+{
+    this->m_channel_list = channel_list;
+    return *this;
+}
+
+// set NSP read update period
+OptionsBuilder &OptionsBuilder::setReadUpdatePeriod(const int rd_update_period)
+{
+    this->m_rd_update_period = rd_update_period;
+    return *this;
+}
+
+// set NSP address
+OptionsBuilder &OptionsBuilder::setNSPAddress(const uint8_t *nsp_address,const int nsp_address_length)
+{
+    if (nsp_address != NULL && nsp_address_length > 0) {
+        int length = nsp_address_length;
+        if (length > NSP_IP_ADDRESS_LENGTH) length = NSP_IP_ADDRESS_LENGTH;
+        for(int i=0; i<length; ++i) this->m_nsp_address[i] = nsp_address[i];
+    }
+    return *this;
+}
+
+// set MAC address
+OptionsBuilder &OptionsBuilder::setMACAddress(const uint8_t *mac_address,const int mac_address_length)
+{
+    if (mac_address != NULL && mac_address_length > 0) {
+        int length = mac_address_length;
+        if (length > NODE_MAC_ADDRESS_LENGTH) length = NODE_MAC_ADDRESS_LENGTH;
+        for(int i=0; i<length; ++i) this->m_mac_address[i] = mac_address[i];
+    }
+    return *this;
+}
+
+// add static resource
+OptionsBuilder &OptionsBuilder::addResource(const StaticResource *resource)
+{
+    this->m_static_resources.push_back((StaticResource *)resource);
+    return *this;
+}
+
+// add dynamic resource
+OptionsBuilder &OptionsBuilder::addResource(const DynamicResource *resource)
+{
+    this->m_dynamic_resources.push_back((DynamicResource *)resource);
+    return *this;
+}
+
+// build out our immutable self
+Options *OptionsBuilder::build()
+{
+    return (Options *)this;
+}
+
+} // namespace Connector