Google Cloud Pub/Sub C++ Client 2.13.0
A C++ Client Library for Google Cloud Pub/Sub
Loading...
Searching...
No Matches
topic.h
1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_TOPIC_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_TOPIC_H
17
18#include "google/cloud/pubsub/version.h"
19#include <grpcpp/grpcpp.h>
20#include <string>
21
22namespace google {
23namespace cloud {
24namespace pubsub {
25GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
26
27/**
28 * Objects of this class identify a Cloud Pub/Sub topic.
29 *
30 * @note
31 * This class makes no effort to validate the ids provided. The application
32 * should verify that any ids passed to this application conform to the
33 * Cloud Pub/Sub [resource name][name-link] restrictions.
34 *
35 * [name-link]: https://cloud.google.com/pubsub/docs/admin#resource_names
36 */
37class Topic {
38 public:
39 Topic(std::string project_id, std::string topic_id)
40 : project_id_(std::move(project_id)), topic_id_(std::move(topic_id)) {}
41
42 /// @name Copy and move
43 ///@{
44 Topic(Topic const&) = default;
45 Topic& operator=(Topic const&) = default;
46 Topic(Topic&&) = default;
47 Topic& operator=(Topic&&) = default;
48 ///@}
49
50 /// Returns the Project ID
51 std::string const& project_id() const { return project_id_; }
52
53 /// Returns the Topic ID
54 std::string const& topic_id() const { return topic_id_; }
55
56 /**
57 * Returns the fully qualified topic name as a string of the form:
58 * "projects/<project-id>/topics/<topic-id>"
59 */
60 std::string FullName() const;
61
62 /// @name Equality operators
63 ///@{
64 friend bool operator==(Topic const& a, Topic const& b);
65 friend bool operator!=(Topic const& a, Topic const& b) { return !(a == b); }
66 ///@}
67
68 /// Output the `FullName()` format.
69 friend std::ostream& operator<<(std::ostream& os, Topic const& rhs);
70
71 private:
72 std::string project_id_;
73 std::string topic_id_;
74};
75
76GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
77} // namespace pubsub
78} // namespace cloud
79} // namespace google
80
81#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_PUBSUB_TOPIC_H
Objects of this class identify a Cloud Pub/Sub topic.
Definition: topic.h:37
Topic & operator=(Topic &&)=default
Topic & operator=(Topic const &)=default
Topic(std::string project_id, std::string topic_id)
Definition: topic.h:39
std::string const & project_id() const
Returns the Project ID.
Definition: topic.h:51
Topic(Topic const &)=default
std::string FullName() const
Returns the fully qualified topic name as a string of the form: "projects/<project-id>/topics/<topic-...
std::string const & topic_id() const
Returns the Topic ID.
Definition: topic.h:54
friend bool operator!=(Topic const &a, Topic const &b)
Definition: topic.h:65
friend bool operator==(Topic const &a, Topic const &b)
Contains all the Cloud Pub/Sub C++ client types and functions.
Definition: ack_handler.h:25
The namespace Google Cloud Platform C++ client libraries.