grpcpp/impl/codegen/grpc_library.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
20 #define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
21 
22 // IWYU pragma: private, include <grpcpp/impl/grpc_library.h>
23 
25 
26 namespace grpc {
27 
29  public:
30  virtual ~GrpcLibraryInterface() = default;
31  virtual void init() = 0;
32  virtual void shutdown() = 0;
33 };
34 
38 
41  public:
42  explicit GrpcLibraryCodegen(bool call_grpc_init = true)
44  if (call_grpc_init) {
46  "gRPC library not initialized. See "
47  "grpc::internal::GrpcLibraryInitializer.");
48  g_glip->init();
49  grpc_init_called_ = true;
50  }
51  }
52  virtual ~GrpcLibraryCodegen() {
53  if (grpc_init_called_) {
55  "gRPC library not initialized. See "
56  "grpc::internal::GrpcLibraryInitializer.");
57  g_glip->shutdown();
58  }
59  }
60 
61  private:
63 };
64 
65 } // namespace grpc
66 
67 #endif // GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
grpc::GrpcLibraryCodegen::~GrpcLibraryCodegen
virtual ~GrpcLibraryCodegen()
Definition: grpcpp/impl/codegen/grpc_library.h:52
grpc
Definition: grpcpp/alarm.h:33
false
#define false
Definition: setup_once.h:323
core_codegen_interface.h
grpc::GrpcLibraryCodegen
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpcpp/impl/codegen/grpc_library.h:40
grpc::GrpcLibraryInterface
Definition: grpcpp/impl/codegen/grpc_library.h:28
grpc::GrpcLibraryInterface::~GrpcLibraryInterface
virtual ~GrpcLibraryInterface()=default
grpc::GrpcLibraryCodegen::GrpcLibraryCodegen
GrpcLibraryCodegen(bool call_grpc_init=true)
Definition: grpcpp/impl/codegen/grpc_library.h:42
grpc::g_glip
GrpcLibraryInterface * g_glip
Definition: codegen_init.cc:30
GPR_CODEGEN_ASSERT
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: grpcpp/impl/codegen/core_codegen_interface.h:151
grpc::GrpcLibraryCodegen::grpc_init_called_
bool grpc_init_called_
Definition: grpcpp/impl/codegen/grpc_library.h:62
grpc::GrpcLibraryInterface::init
virtual void init()=0
grpc::GrpcLibraryInterface::shutdown
virtual void shutdown()=0


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:47