Skip to content

Commit d4d2eb2

Browse files
committed
Noncopyable by default
1 parent f5b602c commit d4d2eb2

File tree

12 files changed

+21
-26
lines changed

12 files changed

+21
-26
lines changed

core/include/core/container_pybindings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ register_vector(py::module_ &scope, std::string name, Args &&...args)
7878
{
7979
using T = typename V::value_type;
8080

81-
auto cls = register_class<V, Bases...>(scope, name, std::forward<Args>(args)...);
81+
auto cls = register_class_copyable<V, Bases...>(scope, name, std::forward<Args>(args)...);
8282

8383
cls.def("__init__", py::make_constructor(container_from_object<V>))
8484
.def("__repr__", vec_repr<T>)
@@ -124,7 +124,7 @@ template <typename M, bool proxy=true, typename... Bases, typename... Args>
124124
auto
125125
register_map(py::module_ &scope, std::string name, Args &&...args)
126126
{
127-
auto cls = register_class<M, Bases...>(scope, name, std::forward<Args>(args)...);
127+
auto cls = register_class_copyable<M, Bases...>(scope, name, std::forward<Args>(args)...);
128128

129129
cls.def(py::init<const M &>())
130130
.def(py::std_map_indexing_suite<M, proxy>())

core/include/core/pybindings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ register_enum(py::module_ &scope, const std::string &name, Args &&... args)
6969
// Ensure that base classes are registered first to inherit their bound methods.
7070
template <typename T, typename... Bases, typename... Args>
7171
auto
72-
register_class(py::module_ &scope, const std::string &name, Args&&...args)
72+
register_class_copyable(py::module_ &scope, const std::string &name, Args&&...args)
7373
{
7474
(void) scope;
7575

@@ -81,7 +81,7 @@ register_class(py::module_ &scope, const std::string &name, Args&&...args)
8181
// Ensure that base classes are registered first to inherit their bound methods.
8282
template <typename T, typename... Bases, typename... Args>
8383
auto
84-
register_class_noncopyable(py::module_ &scope, const std::string &name, Args&&...args)
84+
register_class(py::module_ &scope, const std::string &name, Args&&...args)
8585
{
8686
(void) scope;
8787

@@ -94,7 +94,7 @@ template <typename T, typename... Bases, typename... Args>
9494
auto
9595
register_g3module(py::module_ &scope, const std::string &name, Args&&...args)
9696
{
97-
auto cls = register_class_noncopyable<T, Bases..., G3Module>(scope, name.c_str(),
97+
auto cls = register_class<T, Bases..., G3Module>(scope, name.c_str(),
9898
std::forward<Args>(args)...);
9999

100100
// mark as a module

core/include/core/serialization.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ template <typename T, typename... Bases, typename... Args>
132132
auto
133133
register_frameobject(py::module_ &scope, const std::string &name, Args&&...args)
134134
{
135-
auto cls = register_class<T, Bases..., G3FrameObject>(scope, name.c_str(),
135+
auto cls = register_class_copyable<T, Bases..., G3FrameObject>(scope, name.c_str(),
136136
std::forward<Args>(args)...);
137137

138138
// copy constructor

core/src/G3Frame.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static py::object g3frame_hash(py::object obj)
505505

506506
PYBINDINGS("core", scope) {
507507
// Internal stuff
508-
register_class<G3FrameObject>(scope, "G3FrameObject",
508+
register_class_copyable<G3FrameObject>(scope, "G3FrameObject",
509509
"Base class for objects that can be added to a frame. All such "
510510
"must inherit from G3FrameObject in C++. Pickle hooks are overridden "
511511
"to use the fast internal serialization")
@@ -539,7 +539,7 @@ PYBINDINGS("core", scope) {
539539
;
540540
register_vector_of<G3Frame::FrameType>(scope, "FrameType");
541541

542-
register_class<G3Frame>(scope, "G3Frame",
542+
register_class_copyable<G3Frame>(scope, "G3Frame",
543543
"Frames are the core datatype of the analysis software. They behave "
544544
"like Python dictionaries except that they can only store subclasses "
545545
"of core.G3FrameObject and the dictionary keys must be strings. "

core/src/G3Logging.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ PYBINDINGS("core", scope) {
147147
.value("LOG_FATAL", G3LOG_FATAL)
148148
;
149149

150-
register_class_noncopyable<G3Logger>(scope, "G3Logger", "C++ logging abstract base class")
150+
register_class<G3Logger>(scope, "G3Logger", "C++ logging abstract base class")
151151
.add_static_property("global_logger", &GetRootLogger, &SetRootLogger)
152152
.def("log", &G3Logger::Log)
153153
.def("get_level_for_unit", &G3Logger::LogLevelForUnit)
@@ -156,15 +156,15 @@ PYBINDINGS("core", scope) {
156156
;
157157
register_vector_of<G3LoggerPtr>(scope, "G3Logger");
158158

159-
register_class_noncopyable<G3NullLogger, G3Logger>(scope, "G3NullLogger",
159+
register_class<G3NullLogger, G3Logger>(scope, "G3NullLogger",
160160
"Logger that does not log. Useful if you don't want log messages");
161-
register_class_noncopyable<G3PrintfLogger, G3Logger>(scope, "G3PrintfLogger",
161+
register_class<G3PrintfLogger, G3Logger>(scope, "G3PrintfLogger",
162162
"Logger that prints error messages to stderr (in color, if stderr is a tty).")
163163
.def(py::init<G3LogLevel>((py::arg("default_level")=G3DefaultLogLevel)))
164164
.def_readwrite("trim_file_names", &G3PrintfLogger::TrimFileNames)
165165
.def_readwrite("timestamps", &G3PrintfLogger::Timestamps)
166166
;
167-
register_class_noncopyable<G3MultiLogger, G3Logger>(scope, "G3MultiLogger",
167+
register_class<G3MultiLogger, G3Logger>(scope, "G3MultiLogger",
168168
"Log to multiple loggers at once")
169169
.def(py::init<std::vector<G3LoggerPtr> >())
170170
;

core/src/G3Pipeline.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class G3ModuleWrap : public G3Module, public py::wrapper<G3Module>
417417
};
418418

419419
PYBINDINGS("core", scope) {
420-
register_class_noncopyable<G3ModuleWrap>(scope, "G3Module",
420+
register_class<G3ModuleWrap>(scope, "G3Module",
421421
"Base class for functors that can be added to a G3Pipeline.")
422422
.def(py::init<>())
423423
.def("__call__", &G3Module_Process)

core/src/G3Quat.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ G3TimestreamQuat_nsamples(const G3TimestreamQuat &r)
952952
PYBINDINGS("core", scope)
953953
{
954954
py::object q =
955-
register_class<Quat>(scope, "Quat",
955+
register_class_copyable<Quat>(scope, "Quat",
956956
"Representation of a quaternion. Data in a,b,c,d.")
957957
.def(py::init<>())
958958
.def(py::init<const Quat &>())

dfmux/src/DfMuxBuilder.cxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include <pybindings.h>
22
#include <serialization.h>
3+
#include <container_pybindings.h>
34

45
#include <stdio.h>
56
#include <stdlib.h>
67
#include <unistd.h>
78
#include <sstream>
89

910
#include <dfmux/DfMuxBuilder.h>
10-
#include <std_map_indexing_suite.hpp>
11-
#include <cereal/types/map.hpp>
1211

1312
template <class A> void DfMuxBoardSamples::serialize(A &ar, const unsigned v)
1413
{
@@ -214,11 +213,9 @@ void DfMuxBuilder::ProcessNewData()
214213

215214
PYBINDINGS("dfmux", scope)
216215
{
217-
register_frameobject<DfMuxBoardSamples>(scope, "DfMuxBoardSamples",
216+
register_g3map<DfMuxBoardSamples>(scope, "DfMuxBoardSamples",
218217
"Container structure for samples from modules on one board, mapping "
219218
"0-indexed module and block IDs to a dfmux.DfMuxSample.")
220-
.def(py::init<>())
221-
.def(py::std_map_indexing_suite<DfMuxBoardSamples, true>())
222219
.def_readwrite("nmodules", &DfMuxBoardSamples::nmodules,
223220
"Number of modules expected to report from this board")
224221
.def_readwrite("nblocks", &DfMuxBoardSamples::nblocks,
@@ -229,12 +226,10 @@ PYBINDINGS("dfmux", scope)
229226
"True if this structure contains data from all expected modules and blocks")
230227
;
231228

232-
register_frameobject<DfMuxMetaSample>(scope, "DfMuxMetaSample",
229+
register_g3map<DfMuxMetaSample>(scope, "DfMuxMetaSample",
233230
"Container structure for coincident samples from all boards. "
234231
"Individual board data, stored in dfmux.DfMuxBoardSamples classes, "
235232
"is contained indexed by board serial number.")
236-
.def(py::init<>())
237-
.def(py::std_map_indexing_suite<DfMuxMetaSample, false>())
238233
;
239234

240235
register_g3module<DfMuxBuilder, G3EventBuilder>(scope, "DfMuxBuilder",

dfmux/src/DfMuxCollector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ make_dfmux_collector_v2_from_dict(const char *listenaddr,
446446

447447
PYBINDINGS("dfmux", scope)
448448
{
449-
register_class_noncopyable<DfMuxCollector>(scope, "DfMuxCollector",
449+
register_class<DfMuxCollector>(scope, "DfMuxCollector",
450450
"Listener object that collects IceBoard packets from a single network "
451451
"interface and decodes and forwards them to a DfMuxBuilder object for "
452452
"insertion into the data stream. Takes the builder object to which the "

dfmux/src/LegacyDfMuxCollector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ int LegacyDfMuxCollector::BookPacket(struct DfmuxPacket *packet,
303303

304304
PYBINDINGS("dfmux", scope)
305305
{
306-
register_class_noncopyable<LegacyDfMuxCollector>(scope, "LegacyDfMuxCollector",
306+
register_class<LegacyDfMuxCollector>(scope, "LegacyDfMuxCollector",
307307
"Listener object that collects legacy network packets and decodes and "
308308
"forwards them to a DfMuxBuilder object for insertion into the data "
309309
"stream. Takes a builder object to which the data should be sent. "

0 commit comments

Comments
 (0)