Skip to content

Commit

Permalink
feat!: remove get prefix of builtin type getters (open62541pp#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasberbuer authored Dec 1, 2024
1 parent ab7f4c0 commit 2b2a006
Show file tree
Hide file tree
Showing 22 changed files with 286 additions and 125 deletions.
4 changes: 2 additions & 2 deletions examples/client_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main() {
opcua::services::browseAsync(client, bd, 0, [](opcua::BrowseResult& result) {
std::cout << "Browse result with " << result.getReferences().size() << " references:\n";
for (const auto& reference : result.getReferences()) {
std::cout << "- " << reference.getBrowseName().getName() << std::endl;
std::cout << "- " << reference.getBrowseName().name() << std::endl;
}
});

Expand Down Expand Up @@ -68,7 +68,7 @@ int main() {
<< "Data change notification:\n"
<< "- subscription id: " << subId << "\n"
<< "- monitored item id: " << monId << "\n"
<< "- timestamp: " << dv.getSourceTimestamp() << std::endl;
<< "- timestamp: " << dv.sourceTimestamp() << std::endl;
},
{}, // delete callback
[](opcua::MonitoredItemCreateResult& result) {
Expand Down
6 changes: 3 additions & 3 deletions examples/client_browse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void printNodeTree(opcua::Node<opcua::Client>& node, int indent);
// ...
void printNodeTree(opcua::Node<opcua::Client>& node, int indent) { // NOLINT
for (auto&& child : node.browseChildren()) {
std::cout << std::setw(indent) << "- " << child.readBrowseName().getName() << " ("
std::cout << std::setw(indent) << "- " << child.readBrowseName().name() << " ("
<< getEnumName(child.readNodeClass()) << ")\n";
printNodeTree(child, indent + 2);
}
Expand All @@ -65,6 +65,6 @@ int main() {
// Browse the parent node
auto nodeServerParent = nodeServer.browseParent();

std::cout << nodeServer.readDisplayName().getText() << "'s parent node is "
<< nodeServerParent.readDisplayName().getText() << "\n";
std::cout << nodeServer.readDisplayName().text() << "'s parent node is "
<< nodeServerParent.readDisplayName().text() << "\n";
}
2 changes: 1 addition & 1 deletion examples/client_find_servers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main() {
const auto& name = server.getApplicationUri();
std::cout
<< "Server[" << serverIndex++ << "] " << name << "\n"
<< "\tName: " << server.getApplicationName().getText() << "\n"
<< "\tName: " << server.getApplicationName().text() << "\n"
<< "\tApplication URI: " << server.getApplicationUri() << "\n"
<< "\tProduct URI: " << server.getProductUri() << "\n"
<< "\tApplication type: " << getEnumName(server.getApplicationType()) << "\n"
Expand Down
4 changes: 2 additions & 2 deletions examples/client_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main() {
auto mon = sub.subscribeDataChange(
opcua::VariableId::Server_ServerStatus_CurrentTime, // monitored node id
opcua::AttributeId::Value, // monitored attribute
[&](opcua::IntegerId subId, opcua::IntegerId monId, const opcua::DataValue& value) {
[&](opcua::IntegerId subId, opcua::IntegerId monId, const opcua::DataValue& dv) {
opcua::MonitoredItem item(client, subId, monId);
std::cout
<< "Data change notification:\n"
Expand All @@ -34,7 +34,7 @@ int main() {
<< "- node id: " << item.getNodeId().toString() << "\n"
<< "- attribute id: " << static_cast<int>(item.getAttributeId()) << "\n";

const auto dt = value.getValue().getScalarCopy<opcua::DateTime>();
const auto dt = dv.value().getScalarCopy<opcua::DateTime>();
std::cout << "Current server time (UTC): " << dt.format("%H:%M:%S") << std::endl;
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/events/client_eventfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main() {

std::cout << "Time: " << time.format("%Y-%m-%d %H:%M:%S") << "\n";
std::cout << "Severity: " << severity << "\n";
std::cout << "Message: " << message.getText() << "\n";
std::cout << "Message: " << message.text() << "\n";
}
);

Expand Down
10 changes: 5 additions & 5 deletions examples/server_datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ int main() {

// Define data source with its read and write callbacks
opcua::ValueBackendDataSource dataSource;
dataSource.read = [&](opcua::DataValue& value, const opcua::NumericRange&, bool timestamp) {
dataSource.read = [&](opcua::DataValue& dv, const opcua::NumericRange&, bool timestamp) {
// Increment counter before every read
counter++;
value.getValue().setScalarCopy(counter);
dv.value().setScalarCopy(counter);
if (timestamp) {
value.setSourceTimestamp(opcua::DateTime::now());
dv.setSourceTimestamp(opcua::DateTime::now());
}
std::cout << "Read counter from data source: " << counter << "\n";
return UA_STATUSCODE_GOOD;
};
dataSource.write = [&](const opcua::DataValue& value, const opcua::NumericRange&) {
counter = value.getValue().getScalarCopy<int>();
dataSource.write = [&](const opcua::DataValue& dv, const opcua::NumericRange&) {
counter = dv.value().getScalarCopy<int>();
std::cout << "Write counter to data source: " << counter << "\n";
return UA_STATUSCODE_GOOD;
};
Expand Down
4 changes: 2 additions & 2 deletions examples/server_valuecallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ int main() {

// set variable value callback to write current time before every read operation
opcua::ValueCallback valueCallback;
valueCallback.onBeforeRead = [&](const opcua::DataValue& value) {
const auto timeOld = value.getValue().getScalar<opcua::DateTime>();
valueCallback.onBeforeRead = [&](const opcua::DataValue& dv) {
const auto timeOld = dv.value().getScalar<opcua::DateTime>();
const auto timeNow = opcua::DateTime::now();
std::cout << "Time before read: " << timeOld.format("%Y-%m-%d %H:%M:%S") << std::endl;
std::cout << "Set current time: " << timeNow.format("%Y-%m-%d %H:%M:%S") << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions include/open62541pp/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class Node {
nodes.reserve(refs.size());
for (auto&& ref : refs) {
if (ref.getNodeId().isLocal()) {
nodes.emplace_back(connection(), std::move(ref.getNodeId().getNodeId()));
nodes.emplace_back(connection(), std::move(ref.getNodeId().nodeId()));
}
}
return nodes;
Expand All @@ -625,7 +625,7 @@ class Node {
result.getStatusCode().throwIfBad();
for (auto&& target : result.getTargets()) {
if (target.getTargetId().isLocal()) {
return {connection(), std::move(target.getTargetId().getNodeId())};
return {connection(), std::move(target.getTargetId().nodeId())};
}
}
throw BadStatus(UA_STATUSCODE_BADNOMATCH);
Expand Down Expand Up @@ -1355,7 +1355,7 @@ class Node {
if (!id.isLocal()) {
throw BadStatus(UA_STATUSCODE_BADNODEIDUNKNOWN);
}
return {connection, std::move(id.getNodeId())};
return {connection, std::move(id.nodeId())};
}

template <typename CompletionToken>
Expand All @@ -1378,7 +1378,7 @@ class Node {
result.getStatusCode().throwIfBad();
for (auto&& target : result.getTargets()) {
if (target.getTargetId().isLocal()) {
return {connection(), std::move(target.getTargetId().getNodeId())};
return {connection(), std::move(target.getTargetId().nodeId())};
}
}
throw BadStatus(UA_STATUSCODE_BADNOTFOUND);
Expand Down
6 changes: 3 additions & 3 deletions include/open62541pp/services/detail/attribute_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
namespace opcua::services::detail {

inline Result<Variant> getVariant(DataValue&& dv) noexcept {
if (dv.getStatus().isBad()) {
return BadResult(dv.getStatus());
if (dv.status().isBad()) {
return BadResult(dv.status());
}
if (!dv.hasValue()) {
return BadResult(UA_STATUSCODE_BADUNEXPECTEDERROR);
}
return std::move(dv).getValue();
return std::move(dv).value();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/open62541pp/services/detail/request_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ inline UA_AddNodesItem createAddNodesItem(
item.parentNodeId.nodeId = parentId;
item.referenceTypeId = referenceType;
item.requestedNewNodeId.nodeId = id;
item.browseName.namespaceIndex = id.getNamespaceIndex();
item.browseName.namespaceIndex = id.namespaceIndex();
item.browseName.name = opcua::detail::toNativeString(browseName);
item.nodeClass = static_cast<UA_NodeClass>(nodeClass);
item.nodeAttributes = nodeAttributes;
Expand Down
Loading

0 comments on commit 2b2a006

Please sign in to comment.