1 | #!/usr/bin/perl |
---|
2 | # $Id: CreateNewClass.pl 1004 2004-09-13 22:07:40Z thea $ |
---|
3 | # simple tool to create an empty new class with right headers |
---|
4 | # Author: D. DeMarco, M. Pallavicini, A.Thea |
---|
5 | # |
---|
6 | |
---|
7 | use Getopt::Std; |
---|
8 | getopt('npus'); |
---|
9 | |
---|
10 | use POSIX qw(strftime); |
---|
11 | $now_string = strftime "%Y/%m/%d", gmtime; |
---|
12 | |
---|
13 | |
---|
14 | $singleton = $opt_s; |
---|
15 | $classname = $opt_n; |
---|
16 | $parent = $opt_p; |
---|
17 | |
---|
18 | $classname or die "CreateNewClass: no name defined\n\t usage: CreateNewClass.pl -n name [-s ] [-u <username>] [-p <parent>]"; |
---|
19 | |
---|
20 | $uid = $<; |
---|
21 | $user = (getpwuid($uid))[6]; |
---|
22 | $user=~s/,.*$//; |
---|
23 | |
---|
24 | if ($opt_u) { |
---|
25 | $user = $opt_u; |
---|
26 | } |
---|
27 | |
---|
28 | $aa = $classname; |
---|
29 | $aa=~y/[a-z]/[A-Z]/; |
---|
30 | |
---|
31 | $ifd = "__".$aa."_HH__"; |
---|
32 | $inc = ""; |
---|
33 | if ( $parent ) { |
---|
34 | $inc = "\#include \"$parent.hh\""; |
---|
35 | $classparent = " : public $parent"; |
---|
36 | } |
---|
37 | |
---|
38 | print "creating $classname.hh\n"; |
---|
39 | open(HH,">include/$classname.hh"); |
---|
40 | if ( !$singleton) { |
---|
41 | print HH <<pippo; |
---|
42 | // \$Id\$ |
---|
43 | // Author: $user $now_string |
---|
44 | |
---|
45 | /***************************************************************************** |
---|
46 | * ESAF: Euso Simulation and Analysis Framework * |
---|
47 | * * |
---|
48 | * Id: $classname * |
---|
49 | * Package: <packagename> * |
---|
50 | * Coordinator: <coordinator> * |
---|
51 | * * |
---|
52 | *****************************************************************************/ |
---|
53 | |
---|
54 | \#ifndef $ifd |
---|
55 | \#define $ifd |
---|
56 | |
---|
57 | \#include "euso.hh" |
---|
58 | $inc |
---|
59 | |
---|
60 | //////////////////////////////////////////////////////////////////////////////// |
---|
61 | // // |
---|
62 | // $classname // |
---|
63 | // // |
---|
64 | // <brief class description> // |
---|
65 | // // |
---|
66 | //////////////////////////////////////////////////////////////////////////////// |
---|
67 | |
---|
68 | class $classname$classparent { |
---|
69 | public: |
---|
70 | $classname(); |
---|
71 | virtual ~$classname(); |
---|
72 | |
---|
73 | private: |
---|
74 | |
---|
75 | ClassDef($classname,0) |
---|
76 | }; |
---|
77 | |
---|
78 | \#endif /* $ifd */ |
---|
79 | |
---|
80 | pippo |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | else |
---|
85 | |
---|
86 | { |
---|
87 | print HH <<pippo; |
---|
88 | // \$Id\$ |
---|
89 | // Author: $user $now_string |
---|
90 | |
---|
91 | /***************************************************************************** |
---|
92 | * ESAF: Euso Simulation and Analysis Framework * |
---|
93 | * * |
---|
94 | * Id: $classname * |
---|
95 | * Package: <packagename> * |
---|
96 | * Coordinator: <coordinator> * |
---|
97 | * * |
---|
98 | *****************************************************************************/ |
---|
99 | |
---|
100 | \#ifndef $ifd |
---|
101 | \#define $ifd |
---|
102 | |
---|
103 | \#include "euso.hh" |
---|
104 | $inc |
---|
105 | |
---|
106 | //////////////////////////////////////////////////////////////////////////////// |
---|
107 | // // |
---|
108 | // $classname // |
---|
109 | // // |
---|
110 | // <brief class description> // |
---|
111 | // // |
---|
112 | //////////////////////////////////////////////////////////////////////////////// |
---|
113 | |
---|
114 | class $classname$classparent { |
---|
115 | public: |
---|
116 | virtual ~$classname(); |
---|
117 | |
---|
118 | // instance |
---|
119 | static $classname *Get(); |
---|
120 | |
---|
121 | private: |
---|
122 | $classname(); |
---|
123 | |
---|
124 | // unique instance of $classname |
---|
125 | static $classname *fMe; |
---|
126 | |
---|
127 | ClassDef($classname,0) |
---|
128 | }; |
---|
129 | |
---|
130 | \#endif /* $ifd */ |
---|
131 | |
---|
132 | pippo |
---|
133 | |
---|
134 | } |
---|
135 | close(HH); |
---|
136 | |
---|
137 | print "creating $classname.cc\n"; |
---|
138 | open(CC,">src/$classname.cc"); |
---|
139 | if ( !$singleton) { |
---|
140 | print CC <<pippo; |
---|
141 | // \$Id\$ |
---|
142 | // Author: $user $now_string |
---|
143 | |
---|
144 | /***************************************************************************** |
---|
145 | * ESAF: Euso Simulation and Analysis Framework * |
---|
146 | * * |
---|
147 | * Id: $classname * |
---|
148 | * Package: <packagename> * |
---|
149 | * Coordinator: <coordinator> * |
---|
150 | * * |
---|
151 | *****************************************************************************/ |
---|
152 | |
---|
153 | //_____________________________________________________________________________ |
---|
154 | // |
---|
155 | // $classname |
---|
156 | // |
---|
157 | // <extensive class description> |
---|
158 | // |
---|
159 | // Config file parameters |
---|
160 | // ====================== |
---|
161 | // |
---|
162 | // <parameter name>: <parameter description> |
---|
163 | // -Valid options: <available options> |
---|
164 | // |
---|
165 | |
---|
166 | \#include "$classname.hh" |
---|
167 | |
---|
168 | ClassImp($classname) |
---|
169 | |
---|
170 | //_____________________________________________________________________________ |
---|
171 | $classname\:\:$classname() { |
---|
172 | // |
---|
173 | // Constructor |
---|
174 | // |
---|
175 | |
---|
176 | } |
---|
177 | |
---|
178 | //_____________________________________________________________________________ |
---|
179 | $classname\:\:~$classname() { |
---|
180 | // |
---|
181 | // Destructor |
---|
182 | // |
---|
183 | } |
---|
184 | |
---|
185 | pippo |
---|
186 | |
---|
187 | } |
---|
188 | else { |
---|
189 | print CC <<pippo; |
---|
190 | // \$Id\$ |
---|
191 | // Author: $user $now_string |
---|
192 | |
---|
193 | /***************************************************************************** |
---|
194 | * ESAF: Euso Simulation and Analysis Framework * |
---|
195 | * * |
---|
196 | * Id: $classname * |
---|
197 | * Package: <packagename> * |
---|
198 | * Coordinator: <coordinator> * |
---|
199 | * * |
---|
200 | *****************************************************************************/ |
---|
201 | |
---|
202 | //_____________________________________________________________________________ |
---|
203 | // |
---|
204 | // $classname |
---|
205 | // ========== |
---|
206 | // |
---|
207 | // <extensive class description> |
---|
208 | // |
---|
209 | // Config file parameters |
---|
210 | // ====================== |
---|
211 | // |
---|
212 | // <parameter name>: <parameter description> |
---|
213 | // -Valid options: <available options> |
---|
214 | // |
---|
215 | |
---|
216 | \#include "$classname.hh" |
---|
217 | |
---|
218 | ClassImp($classname) |
---|
219 | |
---|
220 | $classname *$classname\:\:fMe = 0; |
---|
221 | |
---|
222 | //_____________________________________________________________________________ |
---|
223 | $classname\:\:$classname() { |
---|
224 | // |
---|
225 | // Constructor |
---|
226 | // |
---|
227 | } |
---|
228 | |
---|
229 | //_____________________________________________________________________________ |
---|
230 | $classname\:\:~$classname() { |
---|
231 | // |
---|
232 | // Destructor |
---|
233 | // |
---|
234 | } |
---|
235 | |
---|
236 | //_____________________________________________________________________________ |
---|
237 | $classname* $classname\:\:Get() { |
---|
238 | // instance |
---|
239 | if ( fMe == 0 ) |
---|
240 | fMe = new $classname(); |
---|
241 | return fMe; |
---|
242 | } |
---|
243 | |
---|
244 | pippo |
---|
245 | |
---|
246 | } |
---|
247 | |
---|