options.h
Go to the documentation of this file.
1 /*
2  pybind11/options.h: global settings that are configurable at runtime.
3 
4  Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #pragma once
11 
12 #include "detail/common.h"
13 
15 
16 class options {
17 public:
18  // Default RAII constructor, which leaves settings as they currently are.
19  options() : previous_state(global_state()) {}
20 
21  // Class is non-copyable.
22  options(const options &) = delete;
23  options &operator=(const options &) = delete;
24 
25  // Destructor, which restores settings that were in effect before.
26  ~options() { global_state() = previous_state; }
27 
28  // Setter methods (affect the global state):
29 
31  global_state().show_user_defined_docstrings = false;
32  return *this;
33  }
34 
36  global_state().show_user_defined_docstrings = true;
37  return *this;
38  }
39 
41  global_state().show_function_signatures = false;
42  return *this;
43  }
44 
46  global_state().show_function_signatures = true;
47  return *this;
48  }
49 
50  // Getter methods (return the global state):
51 
53  return global_state().show_user_defined_docstrings;
54  }
55 
56  static bool show_function_signatures() { return global_state().show_function_signatures; }
57 
58  // This type is not meant to be allocated on the heap.
59  void *operator new(size_t) = delete;
60 
61 private:
62  struct state {
63  bool show_user_defined_docstrings = true; //< Include user-supplied texts in docstrings.
64  bool show_function_signatures = true; //< Include auto-generated function signatures
65  // in docstrings.
66  };
67 
68  static state &global_state() {
69  static state instance;
70  return instance;
71  }
72 
74 };
75 
options & disable_user_defined_docstrings() &
Definition: options.h:30
options & disable_function_signatures() &
Definition: options.h:40
options & enable_user_defined_docstrings() &
Definition: options.h:35
state previous_state
Definition: options.h:73
The &#39;instance&#39; type which needs to be standard layout (need to be able to use &#39;offsetof&#39;) ...
options()
Definition: options.h:19
idx_t idx_t idx_t idx_t idx_t idx_t idx_t real_t real_t idx_t * options
options & enable_function_signatures() &
Definition: options.h:45
static bool show_function_signatures()
Definition: options.h:56
static state & global_state()
Definition: options.h:68
static bool show_user_defined_docstrings()
Definition: options.h:52
~options()
Definition: options.h:26
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:59