GRPC C++  1.8.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
20 #define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
21 
23 
24 namespace grpc {
25 
27  public:
28  virtual void init() = 0;
29  virtual void shutdown() = 0;
30 };
31 
35 
38  public:
39  GrpcLibraryCodegen(bool call_grpc_init = true) : grpc_init_called_(false) {
40  if (call_grpc_init) {
42  "gRPC library not initialized. See "
43  "grpc::internal::GrpcLibraryInitializer.");
44  g_glip->init();
45  grpc_init_called_ = true;
46  }
47  }
48  virtual ~GrpcLibraryCodegen() {
49  if (grpc_init_called_) {
51  "gRPC library not initialized. See "
52  "grpc::internal::GrpcLibraryInitializer.");
53  g_glip->shutdown();
54  }
55  }
56 
57  private:
58  bool grpc_init_called_;
59 };
60 
61 } // namespace grpc
62 
63 #endif // GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:135
GrpcLibraryInterface * g_glip
Initialized by grpc::GrpcLibraryInitializer from <grpc++/impl/grpc_library.h>
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:37
Definition: grpc_library.h:26
virtual ~GrpcLibraryCodegen()
Definition: grpc_library.h:48
virtual void shutdown()=0
GrpcLibraryCodegen(bool call_grpc_init=true)
Definition: grpc_library.h:39