Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into uprotocol-1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MelamudMichael committed Mar 5, 2024
2 parents 905f3ca + c7060ee commit 32b0e02
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 1 deletion.
7 changes: 6 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UpCpp(ConanFile):
conan_version = None
generators = "CMakeDeps", "PkgConfigDeps", "VirtualRunEnv", "VirtualBuildEnv"
version = "0.1"
exports_sources = "CMakeLists.txt", "up-core-api/*", "include/*" ,"src/*" , "test/*", "cmake/*"
exports_sources = "CMakeLists.txt", "conaninfo/*", "include/*" ,"src/*" , "test/*", "up-core-api/*"

options = {
"shared": [True, False],
Expand All @@ -34,6 +34,11 @@ class UpCpp(ConanFile):
"build_unbundled": False,
"build_cross_compiling": False,
}
up_core_api_version = "1.5.5"

def source(self):
if not self.options.build_unbundled:
//self.run(f"git clone --branch uprotocol-core-api-{self.up_core_api_version} https://github.com/eclipse-uprotocol/up-core-api.git")

def requirements(self):
self.requires("protobuf/3.21.12" + ("@cross/cross" if self.options.build_cross_compiling else ""))
Expand Down
125 changes: 125 additions & 0 deletions include/up-cpp/transport/datamodel/UAttributesBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright (c) 2023 General Motors GTO LLC
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* SPDX-FileType: SOURCE
* SPDX-FileCopyrightText: 2023 General Motors GTO LLC
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _UATTRIBUTESBUILDER_
#define _UATTRIBUTESBUILDER_

#include <string>
#include <spdlog/spdlog.h>
#include <up-core-api/uattributes.pb.h>
#include <up-core-api/uuid.pb.h>
#include <up-core-api/umessage.pb.h>

using namespace uprotocol::uri;
using namespace uprotocol::v1;

namespace uprotocol {

class UAttributesBuilder {
private:
uprotocol::v1::UAttributes attributes_;

public:
UAttributesBuilder() {
attributes_.Clear();
}

UAttributesBuilder(const uprotocol::v1::UUID& id, uprotocol::v1::UMessageType type, uprotocol::v1::UPriority priority) {
attributes_.Clear();
attributes_.mutable_id()->CopyFrom(id);
attributes_.set_type(type);
attributes_.set_priority(priority);
}

UAttributesBuilder& setToken(const std::string& token) {
if (attributes_.has_token()) {
spdlog::error("UAttributes already has a token set. Ignoring setToken()");
return *this;
}
attributes_.set_token(token);
return *this;
}

UAttributesBuilder& setId(const uprotocol::v1::UUID& id) {
if (attributes_.has_id()) {
spdlog::error("UAttributes already has an id set. Ignoring setId()");
return *this;
}
attributes_.mutable_id()->CopyFrom(id);
return *this;
}

UAttributesBuilder& setSink(const uprotocol::v1::UUri& sink) {
if (attributes_.has_sink()) {
spdlog::error("UAttributes already has a sink set. Ignoring setSink()");
return *this;
}
attributes_.mutable_sink()->CopyFrom(sink);
return *this;
}

UAttributesBuilder& setReqid(const uprotocol::v1::UUID& reqid) {
if (attributes_.has_reqid()) {
spdlog::error("UAttributes already has a reqid set. Ignoring setReqid()");
return *this;
}
attributes_.mutable_reqid()->CopyFrom(reqid);
return *this;
}

UAttributesBuilder& setType(uprotocol::v1::UMessageType type) {
attributes_.set_type(type);
return *this;
}

UAttributesBuilder& setPriority(uprotocol::v1::UPriority priority) {
attributes_.set_priority(priority);
return *this;
}

UAttributesBuilder& setTtl(int32_t ttl) {
attributes_.set_ttl(ttl);
return *this;
}

UAttributesBuilder& setPermissionLevel(int32_t permission_level) {
attributes_.set_permission_level(permission_level);
return *this;
}

UAttributesBuilder& setCommstatus(int32_t commstatus) {
attributes_.set_commstatus(commstatus);
return *this;
}

uprotocol::v1::UAttributes build() const {
return attributes_;
}
};

} // namespace uprotocol


#endif /* _UATTRIBUTESBUILDER_*/

0 comments on commit 32b0e02

Please sign in to comment.