Adding getDeepProxy functionallity to VABElementProxy
Change-Id: Id7092d4ed4a20b0e4c633db6f3adfe456442c5cc
Signed-off-by: Johannes Wendel <johannes.wendel@iese.fraunhofer.de>
diff --git a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/IVABElementProxy.h b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/IVABElementProxy.h
index 01268ed..d6a7f05 100644
--- a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/IVABElementProxy.h
+++ b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/IVABElementProxy.h
@@ -29,6 +29,8 @@
virtual void deleteElement(const VABPath& elementPath) = 0;
virtual void deleteElement(const VABPath& elementPath, const basyx::any& value) = 0;
virtual basyx::any invoke(const VABPath& elementPath, basyx::objectCollection_t& parameter) = 0;
+ virtual std::shared_ptr<IVABElementProxy> getDeepProxy(const VABPath& elementPath) = 0;
+ virtual VABPath getAddressPath() const = 0;
};
}
diff --git a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.cpp b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.cpp
index 4858e40..9ae21d9 100644
--- a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.cpp
+++ b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.cpp
@@ -51,6 +51,17 @@
return this->provider->invokeOperationImpl(this->get_ablsolute_path(elementPath), parameter);
}
+std::shared_ptr<IVABElementProxy> VABElementProxy::getDeepProxy(const VABPath & elementPath)
+{
+ auto new_path = this->address + elementPath;
+ return std::make_shared<VABElementProxy>(new_path, this->provider);
+}
+
+VABPath VABElementProxy::getAddressPath() const
+{
+ return this->address.toString();
+}
+
VABPath VABElementProxy::get_ablsolute_path(const VABPath & elementPath)
{
return this->address + elementPath;
diff --git a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.h b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.h
index 33937e8..2241f30 100644
--- a/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.h
+++ b/sdks/c++/basys.sdk.cc/src/vab/vab/core/proxy/VABElementProxy.h
@@ -32,6 +32,8 @@
virtual void deleteElement(const VABPath& elementPath) override;
virtual void deleteElement(const VABPath& elementPath, const basyx::any& value) override;
virtual basyx::any invoke(const VABPath& elementPath, basyx::objectCollection_t& parameter) override;
+ virtual std::shared_ptr<IVABElementProxy> getDeepProxy(const VABPath & elementPath) override;
+ virtual VABPath getAddressPath() const override;
private:
VABPath get_ablsolute_path(const VABPath& elementPath);
@@ -39,6 +41,7 @@
private:
VABPath address;
std::shared_ptr<IModelProvider> provider;
+
};
}
diff --git a/sdks/c++/basys.sdk.cc/tests/regression/aas/support/VABProxyMock.cpp b/sdks/c++/basys.sdk.cc/tests/regression/aas/support/VABProxyMock.cpp
index 05472b6..34490f1 100644
--- a/sdks/c++/basys.sdk.cc/tests/regression/aas/support/VABProxyMock.cpp
+++ b/sdks/c++/basys.sdk.cc/tests/regression/aas/support/VABProxyMock.cpp
@@ -81,9 +81,22 @@
return basyx::any("called with " + elementPath.toString());
}
+ virtual std::shared_ptr<IVABElementProxy> getDeepProxy(const VABPath & elementPath) override
+ {
+ getDeepProxyCalls++;
+ return std::shared_ptr<IVABElementProxy>();
+ }
+
+ virtual VABPath getAddressPath() const override
+ {
+ VABProxyMockUp* ptr = const_cast<VABProxyMockUp*> (this);
+ ptr->getAddressPathCalls++;
+ return VABPath("");
+ }
+
int overallMockCalls()
{
- return readElementValue_calls + updateElementValue_calls + createElement_calls + deleteElement_calls + deleteElement2_calls + invoke_calls;
+ return readElementValue_calls + updateElementValue_calls + createElement_calls + deleteElement_calls + deleteElement2_calls + invoke_calls + getDeepProxyCalls + getAddressPathCalls;
}
int readElementValue_calls = 0;
@@ -92,6 +105,8 @@
int deleteElement_calls = 0;
int deleteElement2_calls = 0;
int invoke_calls = 0;
+ int getDeepProxyCalls = 0;
+ int getAddressPathCalls = 0;
std::vector<std::pair<std::string, basyx::any>> updateElementCallValues;
std::vector<std::pair<std::string, basyx::any>> createElementCallValues;
@@ -100,6 +115,7 @@
std::vector<std::string> removeElementCallValues;
basyx::objectMap_t map;
basyx::objectCollection_t collection, invokeCallParameter;
+
};
using VABProxyMock = VABProxyMockUp<ProxyType::Default>;
diff --git a/sdks/c++/basys.sdk.cc/tests/regression/vab/core/proxy/test_vab_elementproxy.cpp b/sdks/c++/basys.sdk.cc/tests/regression/vab/core/proxy/test_vab_elementproxy.cpp
index a08eb42..be35c15 100644
--- a/sdks/c++/basys.sdk.cc/tests/regression/vab/core/proxy/test_vab_elementproxy.cpp
+++ b/sdks/c++/basys.sdk.cc/tests/regression/vab/core/proxy/test_vab_elementproxy.cpp
@@ -144,3 +144,16 @@
ASSERT_EQ(collection.size(), provider_mockup->val.Get<basyx::objectCollection_t&>().size());
ASSERT_EQ(2, provider_mockup->val.Get<basyx::objectCollection_t&>().at(0).Get<int>());
}
+
+TEST_F(BasyxVABElementProxy, TestGetDeepProxy)
+{
+ std::shared_ptr<vab::core::proxy::IVABElementProxy> proxy(new vab::core::proxy::VABElementProxy(proxy_address, provider_mockup));
+
+ auto deep_proxy = proxy->getDeepProxy("another/path");
+
+ // The initial path should be combined with the new path
+ ASSERT_EQ("basyx://127.0.0.1//another/path", deep_proxy->getAddressPath().toString());
+ // No Mockup function should have been called
+ ASSERT_EQ(MockupModelProvider::CalledFunction::NONE, provider_mockup->called);
+}
+