-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathextensions.hpp
More file actions
45 lines (34 loc) · 1.5 KB
/
extensions.hpp
File metadata and controls
45 lines (34 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef CHALLENGE_extensions_hpp_INCLUDED
#define CHALLENGE_extensions_hpp_INCLUDED
#include "basics.hpp"
namespace extensions {
// In Python, we'd like to wrap this as a single Thingamajig type with
// a "dtype" attribute and constructor argument that can be either of
// (double, std::shared_ptr<Doodad>), mimicking the way numpy.ndarray
// handles multiple types. Actually using NumPy is optional.
template <typename T>
class Thingamajig : public basics::Doodad {
public:
// Keyword arguments and default values should work in Python.
Thingamajig(T extra, std::string const & name, int value=1);
// Copy construction is disabled to ensure bindings don't make unnecessary
// copies.
Thingamajig(Thingamajig const &) = delete;
Thingamajig& operator=(Thingamajig const &) = delete;
// Move construction is allowed, but is not expected to be exposed to
// Python.
Thingamajig(Thingamajig &&) = default;
Thingamajig& operator=(Thingamajig &&) = default;
// In Python, this shouldn't have to be wrapped for Thingamajig, as
// Python inheritance from Doodad should delegate to the Thingamajig
// implementation anyway. It should, however, return a Thingamajig
// instance in Python, not a Doodad that would have to be casted
// somehow.
virtual std::unique_ptr<basics::Doodad> clone() const;
// Return the extra object.
T get_extra() const { return _extra; }
private:
T _extra;
};
} // namespace things
#endif //! CHALLENGE_extensions_hpp_INCLUDED