Skip to content

Commit df26782

Browse files
perf: improve setting incoming property
creating nlohmann to use applyState was much slower than use a function designed to handle one proeprty - with already existing variables
1 parent a7789d4 commit df26782

File tree

44 files changed

+422
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+422
-26
lines changed

goldenmaster/modules/tb_enum_module/tb_enum/generated/olink/enuminterfaceclient.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ void EnumInterfaceClient::applyState(const nlohmann::json& fields)
3535
}
3636
}
3737

38+
void EnumInterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
39+
{
40+
if ( propertyName == "prop0") {
41+
setProp0Local(value.get<Enum0Enum>());
42+
}
43+
else if ( propertyName == "prop1") {
44+
setProp1Local(value.get<Enum1Enum>());
45+
}
46+
else if ( propertyName == "prop2") {
47+
setProp2Local(value.get<Enum2Enum>());
48+
}
49+
else if ( propertyName == "prop3") {
50+
setProp3Local(value.get<Enum3Enum>());
51+
}
52+
}
53+
3854
void EnumInterfaceClient::setProp0(Enum0Enum prop0)
3955
{
4056
if(!m_node) {
@@ -279,7 +295,7 @@ void EnumInterfaceClient::olinkOnSignal(const std::string& signalId, const nlohm
279295

280296
void EnumInterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
281297
{
282-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
298+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
283299
}
284300
void EnumInterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
285301
{

goldenmaster/modules/tb_enum_module/tb_enum/generated/olink/enuminterfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ class TEST_TB_ENUM_EXPORT EnumInterfaceClient : public IEnumInterface,
163163
* @param the data received from EnumInterface service.
164164
*/
165165
void applyState(const nlohmann::json& fields);
166+
/**
167+
* Applies received property value to local state and publishes changes to subscribers.
168+
* @param propertyName the name of property to be changed.
169+
* @param value The value for property.
170+
*/
171+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
166172
/** Updates local value for Prop0 and informs subscriber about the change*/
167173
void setProp0Local(Enum0Enum prop0);
168174
/** Updates local value for Prop1 and informs subscriber about the change*/

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/sameenum1interfaceclient.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ void SameEnum1InterfaceClient::applyState(const nlohmann::json& fields)
2626
}
2727
}
2828

29+
void SameEnum1InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
30+
{
31+
if ( propertyName == "prop1") {
32+
setProp1Local(value.get<Enum1Enum>());
33+
}
34+
}
35+
2936
void SameEnum1InterfaceClient::setProp1(Enum1Enum prop1)
3037
{
3138
if(!m_node) {
@@ -96,7 +103,7 @@ void SameEnum1InterfaceClient::olinkOnSignal(const std::string& signalId, const
96103

97104
void SameEnum1InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
98105
{
99-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
106+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
100107
}
101108
void SameEnum1InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
102109
{

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/sameenum1interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class TEST_TB_SAME1_EXPORT SameEnum1InterfaceClient : public ISameEnum1Interface
106106
* @param the data received from SameEnum1Interface service.
107107
*/
108108
void applyState(const nlohmann::json& fields);
109+
/**
110+
* Applies received property value to local state and publishes changes to subscribers.
111+
* @param propertyName the name of property to be changed.
112+
* @param value The value for property.
113+
*/
114+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
109115
/** Updates local value for Prop1 and informs subscriber about the change*/
110116
void setProp1Local(Enum1Enum prop1);
111117

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/sameenum2interfaceclient.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void SameEnum2InterfaceClient::applyState(const nlohmann::json& fields)
2929
}
3030
}
3131

32+
void SameEnum2InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
33+
{
34+
if ( propertyName == "prop1") {
35+
setProp1Local(value.get<Enum1Enum>());
36+
}
37+
else if ( propertyName == "prop2") {
38+
setProp2Local(value.get<Enum2Enum>());
39+
}
40+
}
41+
3242
void SameEnum2InterfaceClient::setProp1(Enum1Enum prop1)
3343
{
3444
if(!m_node) {
@@ -158,7 +168,7 @@ void SameEnum2InterfaceClient::olinkOnSignal(const std::string& signalId, const
158168

159169
void SameEnum2InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
160170
{
161-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
171+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
162172
}
163173
void SameEnum2InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
164174
{

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/sameenum2interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class TEST_TB_SAME1_EXPORT SameEnum2InterfaceClient : public ISameEnum2Interface
125125
* @param the data received from SameEnum2Interface service.
126126
*/
127127
void applyState(const nlohmann::json& fields);
128+
/**
129+
* Applies received property value to local state and publishes changes to subscribers.
130+
* @param propertyName the name of property to be changed.
131+
* @param value The value for property.
132+
*/
133+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
128134
/** Updates local value for Prop1 and informs subscriber about the change*/
129135
void setProp1Local(Enum1Enum prop1);
130136
/** Updates local value for Prop2 and informs subscriber about the change*/

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/samestruct1interfaceclient.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ void SameStruct1InterfaceClient::applyState(const nlohmann::json& fields)
2626
}
2727
}
2828

29+
void SameStruct1InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
30+
{
31+
if ( propertyName == "prop1") {
32+
setProp1Local(value.get<Struct1>());
33+
}
34+
}
35+
2936
void SameStruct1InterfaceClient::setProp1(const Struct1& prop1)
3037
{
3138
if(!m_node) {
@@ -96,7 +103,7 @@ void SameStruct1InterfaceClient::olinkOnSignal(const std::string& signalId, cons
96103

97104
void SameStruct1InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
98105
{
99-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
106+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
100107
}
101108
void SameStruct1InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
102109
{

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/samestruct1interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class TEST_TB_SAME1_EXPORT SameStruct1InterfaceClient : public ISameStruct1Inter
106106
* @param the data received from SameStruct1Interface service.
107107
*/
108108
void applyState(const nlohmann::json& fields);
109+
/**
110+
* Applies received property value to local state and publishes changes to subscribers.
111+
* @param propertyName the name of property to be changed.
112+
* @param value The value for property.
113+
*/
114+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
109115
/** Updates local value for Prop1 and informs subscriber about the change*/
110116
void setProp1Local(const Struct1& prop1);
111117

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/samestruct2interfaceclient.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void SameStruct2InterfaceClient::applyState(const nlohmann::json& fields)
2929
}
3030
}
3131

32+
void SameStruct2InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
33+
{
34+
if ( propertyName == "prop1") {
35+
setProp1Local(value.get<Struct2>());
36+
}
37+
else if ( propertyName == "prop2") {
38+
setProp2Local(value.get<Struct2>());
39+
}
40+
}
41+
3242
void SameStruct2InterfaceClient::setProp1(const Struct2& prop1)
3343
{
3444
if(!m_node) {
@@ -158,7 +168,7 @@ void SameStruct2InterfaceClient::olinkOnSignal(const std::string& signalId, cons
158168

159169
void SameStruct2InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
160170
{
161-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
171+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
162172
}
163173
void SameStruct2InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
164174
{

goldenmaster/modules/tb_same1_module/tb_same1/generated/olink/samestruct2interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class TEST_TB_SAME1_EXPORT SameStruct2InterfaceClient : public ISameStruct2Inter
125125
* @param the data received from SameStruct2Interface service.
126126
*/
127127
void applyState(const nlohmann::json& fields);
128+
/**
129+
* Applies received property value to local state and publishes changes to subscribers.
130+
* @param propertyName the name of property to be changed.
131+
* @param value The value for property.
132+
*/
133+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
128134
/** Updates local value for Prop1 and informs subscriber about the change*/
129135
void setProp1Local(const Struct2& prop1);
130136
/** Updates local value for Prop2 and informs subscriber about the change*/

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/sameenum1interfaceclient.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ void SameEnum1InterfaceClient::applyState(const nlohmann::json& fields)
2626
}
2727
}
2828

29+
void SameEnum1InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
30+
{
31+
if ( propertyName == "prop1") {
32+
setProp1Local(value.get<Enum1Enum>());
33+
}
34+
}
35+
2936
void SameEnum1InterfaceClient::setProp1(Enum1Enum prop1)
3037
{
3138
if(!m_node) {
@@ -96,7 +103,7 @@ void SameEnum1InterfaceClient::olinkOnSignal(const std::string& signalId, const
96103

97104
void SameEnum1InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
98105
{
99-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
106+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
100107
}
101108
void SameEnum1InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
102109
{

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/sameenum1interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class TEST_TB_SAME2_EXPORT SameEnum1InterfaceClient : public ISameEnum1Interface
106106
* @param the data received from SameEnum1Interface service.
107107
*/
108108
void applyState(const nlohmann::json& fields);
109+
/**
110+
* Applies received property value to local state and publishes changes to subscribers.
111+
* @param propertyName the name of property to be changed.
112+
* @param value The value for property.
113+
*/
114+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
109115
/** Updates local value for Prop1 and informs subscriber about the change*/
110116
void setProp1Local(Enum1Enum prop1);
111117

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/sameenum2interfaceclient.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void SameEnum2InterfaceClient::applyState(const nlohmann::json& fields)
2929
}
3030
}
3131

32+
void SameEnum2InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
33+
{
34+
if ( propertyName == "prop1") {
35+
setProp1Local(value.get<Enum1Enum>());
36+
}
37+
else if ( propertyName == "prop2") {
38+
setProp2Local(value.get<Enum2Enum>());
39+
}
40+
}
41+
3242
void SameEnum2InterfaceClient::setProp1(Enum1Enum prop1)
3343
{
3444
if(!m_node) {
@@ -158,7 +168,7 @@ void SameEnum2InterfaceClient::olinkOnSignal(const std::string& signalId, const
158168

159169
void SameEnum2InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
160170
{
161-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
171+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
162172
}
163173
void SameEnum2InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
164174
{

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/sameenum2interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class TEST_TB_SAME2_EXPORT SameEnum2InterfaceClient : public ISameEnum2Interface
125125
* @param the data received from SameEnum2Interface service.
126126
*/
127127
void applyState(const nlohmann::json& fields);
128+
/**
129+
* Applies received property value to local state and publishes changes to subscribers.
130+
* @param propertyName the name of property to be changed.
131+
* @param value The value for property.
132+
*/
133+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
128134
/** Updates local value for Prop1 and informs subscriber about the change*/
129135
void setProp1Local(Enum1Enum prop1);
130136
/** Updates local value for Prop2 and informs subscriber about the change*/

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/samestruct1interfaceclient.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ void SameStruct1InterfaceClient::applyState(const nlohmann::json& fields)
2626
}
2727
}
2828

29+
void SameStruct1InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
30+
{
31+
if ( propertyName == "prop1") {
32+
setProp1Local(value.get<Struct1>());
33+
}
34+
}
35+
2936
void SameStruct1InterfaceClient::setProp1(const Struct1& prop1)
3037
{
3138
if(!m_node) {
@@ -96,7 +103,7 @@ void SameStruct1InterfaceClient::olinkOnSignal(const std::string& signalId, cons
96103

97104
void SameStruct1InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
98105
{
99-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
106+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
100107
}
101108
void SameStruct1InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
102109
{

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/samestruct1interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class TEST_TB_SAME2_EXPORT SameStruct1InterfaceClient : public ISameStruct1Inter
106106
* @param the data received from SameStruct1Interface service.
107107
*/
108108
void applyState(const nlohmann::json& fields);
109+
/**
110+
* Applies received property value to local state and publishes changes to subscribers.
111+
* @param propertyName the name of property to be changed.
112+
* @param value The value for property.
113+
*/
114+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
109115
/** Updates local value for Prop1 and informs subscriber about the change*/
110116
void setProp1Local(const Struct1& prop1);
111117

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/samestruct2interfaceclient.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void SameStruct2InterfaceClient::applyState(const nlohmann::json& fields)
2929
}
3030
}
3131

32+
void SameStruct2InterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
33+
{
34+
if ( propertyName == "prop1") {
35+
setProp1Local(value.get<Struct2>());
36+
}
37+
else if ( propertyName == "prop2") {
38+
setProp2Local(value.get<Struct2>());
39+
}
40+
}
41+
3242
void SameStruct2InterfaceClient::setProp1(const Struct2& prop1)
3343
{
3444
if(!m_node) {
@@ -158,7 +168,7 @@ void SameStruct2InterfaceClient::olinkOnSignal(const std::string& signalId, cons
158168

159169
void SameStruct2InterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
160170
{
161-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
171+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
162172
}
163173
void SameStruct2InterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
164174
{

goldenmaster/modules/tb_same2_module/tb_same2/generated/olink/samestruct2interfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class TEST_TB_SAME2_EXPORT SameStruct2InterfaceClient : public ISameStruct2Inter
125125
* @param the data received from SameStruct2Interface service.
126126
*/
127127
void applyState(const nlohmann::json& fields);
128+
/**
129+
* Applies received property value to local state and publishes changes to subscribers.
130+
* @param propertyName the name of property to be changed.
131+
* @param value The value for property.
132+
*/
133+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
128134
/** Updates local value for Prop1 and informs subscriber about the change*/
129135
void setProp1Local(const Struct2& prop1);
130136
/** Updates local value for Prop2 and informs subscriber about the change*/

goldenmaster/modules/tb_simple_module/tb_simple/generated/olink/nooperationsinterfaceclient.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void NoOperationsInterfaceClient::applyState(const nlohmann::json& fields)
2929
}
3030
}
3131

32+
void NoOperationsInterfaceClient::applyProperty(const std::string& propertyName, const nlohmann::json& value)
33+
{
34+
if ( propertyName == "propBool") {
35+
setPropBoolLocal(value.get<bool>());
36+
}
37+
else if ( propertyName == "propInt") {
38+
setPropIntLocal(value.get<int>());
39+
}
40+
}
41+
3242
void NoOperationsInterfaceClient::setPropBool(bool propBool)
3343
{
3444
if(!m_node) {
@@ -95,7 +105,7 @@ void NoOperationsInterfaceClient::olinkOnSignal(const std::string& signalId, con
95105

96106
void NoOperationsInterfaceClient::olinkOnPropertyChanged(const std::string& propertyId, const nlohmann::json& value)
97107
{
98-
applyState({ {ApiGear::ObjectLink::Name::getMemberName(propertyId), value} });
108+
applyProperty(ApiGear::ObjectLink::Name::getMemberName(propertyId), value);
99109
}
100110
void NoOperationsInterfaceClient::olinkOnInit(const std::string& /*name*/, const nlohmann::json& props, ApiGear::ObjectLink::IClientNode *node)
101111
{

goldenmaster/modules/tb_simple_module/tb_simple/generated/olink/nooperationsinterfaceclient.h

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ class TEST_TB_SIMPLE_EXPORT NoOperationsInterfaceClient : public INoOperationsIn
107107
* @param the data received from NoOperationsInterface service.
108108
*/
109109
void applyState(const nlohmann::json& fields);
110+
/**
111+
* Applies received property value to local state and publishes changes to subscribers.
112+
* @param propertyName the name of property to be changed.
113+
* @param value The value for property.
114+
*/
115+
void applyProperty(const std::string& propertyName, const nlohmann::json& value);
110116
/** Updates local value for PropBool and informs subscriber about the change*/
111117
void setPropBoolLocal(bool propBool);
112118
/** Updates local value for PropInt and informs subscriber about the change*/

0 commit comments

Comments
 (0)