-
Notifications
You must be signed in to change notification settings - Fork 31
/
new-mod
executable file
·79 lines (60 loc) · 1.36 KB
/
new-mod
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /bin/sh
if test $# '=' 0 || test 'x'"$1" '=' x--help; then
echo Usage: $0 NewModuleName
exit 0
fi
NAME="$1"
CAPSNAME="`echo $NAME | tr '[a-z]' '[A-Z]'`"
cat > Boss/Mod/$NAME.hpp <<HEADERFILE
#ifndef BOSS_MOD_${CAPSNAME}_HPP
#define BOSS_MOD_${CAPSNAME}_HPP
#include<memory>
namespace S { class Bus; }
namespace Boss { namespace Mod {
/** class Boss::Mod::${NAME}
*
* @brief <describe your module here>
*/
class ${NAME} {
private:
class Impl;
std::unique_ptr<Impl> pimpl;
public:
${NAME}() =delete;
${NAME}(${NAME}&&);
~${NAME}();
/* Formal constructor. */
explicit
${NAME}(S::Bus&);
};
}}
#endif /* !defined(BOSS_MOD_${CAPSNAME}_HPP) */
HEADERFILE
cat > Boss/Mod/$NAME.cpp <<SOURCEFILE
#include"Boss/Mod/${NAME}.hpp"
#include"Ev/Io.hpp"
#include"S/Bus.hpp"
#include"Util/make_unique.hpp"
namespace Boss { namespace Mod {
class ${NAME}::Impl {
private:
S::Bus& bus;
/* <insert your data here> */
void start() {
/* <insert bus.subscribe calls here> */
}
public:
Impl() =delete;
Impl(Impl&&) =delete;
explicit
Impl(S::Bus& bus_) : bus(bus_) { start(); }
};
/* Use default implementations. */
${NAME}::${NAME}(${NAME}&&) =default;
${NAME}::~${NAME}() =default;
/* Construct the implementation. */
${NAME}::${NAME}(S::Bus& bus)
: pimpl(Util::make_unique<Impl>(bus)) { }
}}
SOURCEFILE
echo "Please add ${NAME} to Makefile.am and Boss/Mod/all.cpp"