1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef JNI_BUNDLERESOURCE_H_
22 #define JNI_BUNDLERESOURCE_H_
28 #include "BundleResource.h"
29 #include "SoftSensorResource.h"
30 #include "ResourceContainerImpl.h"
36 void initRCSJniBundleResource(JNIEnvWrapper *);
44 class JniBundleResource: public SoftSensorResource
48 JniBundleResource(JNIEnv *env, jobject obj, jobject bundleResource, string bundleId,
49 jobjectArray attributes);
50 virtual ~JniBundleResource();
52 void handleSetAttributeRequest(const std::string& key,
53 RCSResourceAttributes::Value&&);
55 RCSResourceAttributes::Value handleGetAttributeRequest(const std::string& key);
57 virtual void handleSetAttributesRequest(const RCSResourceAttributes &attrs);
59 virtual RCSResourceAttributes handleGetAttributesRequest();
62 * SoftSensor logic. Has to be provided by the soft sensor developer.
63 * This function will be executed if an input attribute is updated.
67 virtual void executeLogic();
70 * Callback from the client module in the container.
71 * This function will be called if input data from remote resources are updated.
72 * SoftSensor resource can get a vector of input data from multiple input resources
73 * which have attributeName that softsensor needs to execute its logic.
75 * @param attributeName Attribute key of input data
77 * @param values Vector of input data value
81 virtual void onUpdatedInputResource(const std::string attributeName,
82 std::vector<RCSResourceAttributes::Value> values);
84 virtual void initAttributes();
86 // needs to be a GlobalRef
87 jobject m_bundleResource;
88 jobjectArray m_attributes;
89 jclass m_bundleResourceClass;
90 jmethodID m_attributeSetRequestHandler;
91 jmethodID m_attributeGetRequestHandler;
92 jmethodID m_onUpdatedInputResource;
94 jmethodID m_vectorAddMethod;
100 jfieldID g_field_mNativeHandle;
109 * Class: org_iotivity_service_resourcecontainer_JniBundleResource
110 * Method: updateNativeInstance
111 * Signature: (Lorg/iotivity/service/resourcecontainer/RcsResourceAttributes;)V
113 JNIEXPORT void JNICALL Java_org_iotivity_service_resourcecontainer_BundleResource_updateNativeInstance
114 (JNIEnv *, jobject, jobject);