22void parseTemplate( std::string dir, std::string filename, std::string dname ) {
23 std::string outname = dname;
24 std::string outfile = dir + outname +
".temp";
25 ofstream out( outfile.c_str() );
26 ifstream in( ( dir + filename ).c_str() );
30 while ( ( buffer =
getLine( in ) ) !=
"eof" )
32 while ( ( i = buffer.find(
"@NAME" ) ) != std::string::npos )
34 if ( i > 0 ) buffer.replace( i, 5, outname );
36 out << buffer << std::endl;
43 make =
new G4UIcommand(
"/Project/make",
this );
44 make->SetGuidance(
"Builds the specified project" );
45 G4UIparameter* parameter;
47 parameter =
new G4UIparameter(
"Project",
's', omitable =
false );
48 make->SetParameter( parameter );
50 create =
new G4UIcommand(
"/Project/create",
this );
51 create->SetGuidance(
"Creates an empty project" );
52 parameter =
new G4UIparameter(
"Project",
's', omitable =
false );
53 create->SetParameter( parameter );
55 del =
new G4UIcommand(
"/Project/delete",
this );
56 del->SetGuidance(
"Deletes a project" );
57 parameter =
new G4UIparameter(
"Project",
's', omitable =
false );
58 del->SetParameter( parameter );
60 geo =
new G4UIcommand(
"/Project/add/DetectorFacility",
this );
61 geo->SetGuidance(
"Generates sample code for a detector facility in a project" );
62 parameter =
new G4UIparameter(
"Project",
's', omitable =
false );
63 geo->SetParameter( parameter );
65 G4UIparameter* parameter2;
66 parameter2 =
new G4UIparameter(
"DetectorFacilityName",
's', omitable =
false );
67 geo->SetParameter( parameter2 );
69 act =
new G4UIcommand(
"/Project/add/UserAction",
this );
70 act->SetGuidance(
"Generates sample code for an user action in a project" );
71 parameter =
new G4UIparameter(
"Project",
's', omitable =
false );
72 act->SetParameter( parameter );
74 G4UIparameter* parameter3;
75 parameter3 =
new G4UIparameter(
"UserAction Name",
's', omitable =
false );
76 act->SetParameter( parameter3 );
88 if ( command == make ) {
Goofy::Shell(
"cd " + newValues +
"; gmake" ); }
89 else if ( command == create )
95 std::cout <<
"Looking for " << std::flush;
96 if (
Goofy::Shell(
"find $FADS_CURRENT/config -name GNUmakefile_template" ) == 0 )
98 std::cout <<
" Found! " << std::endl;
99 Goofy::Shell(
"cp $FADS_CURRENT/config/GNUmakefile_template " + newValues +
104 else if ( command == del )
108 else if ( command == geo )
110 G4String detName, project;
111 const char*
s = newValues;
112 std::istrstream is( (
char*)
s );
113 is >> project >> detName;
117 std::string where =
"$FADS_CURRENT/config/";
118 std::string incl = project +
"/include/";
119 std::string src = project +
"/src/";
120 Goofy::Shell(
"cp " + where +
"DetectorFacilityTemplate.hh " + incl );
121 parseTemplate( incl,
"DetectorFacilityTemplate.hh", detName );
122 Goofy::Shell(
"mv " + incl + detName +
".temp " + incl + +detName +
"Facility.hh" );
123 Goofy::Shell(
"rm -f " + incl +
"DetectorFacilityTemplate.hh" );
124 Goofy::Shell(
"cp " + where +
"DetectorFacilityTemplate.cc " + src );
125 parseTemplate( src,
"DetectorFacilityTemplate.cc", detName );
126 Goofy::Shell(
"mv " + src + detName +
".temp " + src + +detName +
"Facility.cc" );
127 Goofy::Shell(
"rm -f " + src +
"DetectorFacilityTemplate.cc" );
130 else if ( command == act )
132 G4String actName, project;
133 const char*
s = newValues;
134 std::istrstream is( (
char*)
s );
135 is >> project >> actName;
139 std::string where =
"$FADS_CURRENT/config/";
140 std::string incl = project +
"/include/";
141 std::string src = project +
"/src/";
142 Goofy::Shell(
"cp " + where +
"UserActionTemplate.hh " + incl );
144 Goofy::Shell(
"mv " + incl + actName +
".temp " + incl + +actName +
"Action.hh" );
145 Goofy::Shell(
"rm -f " + incl +
"UserActionTemplate.hh" );
146 Goofy::Shell(
"cp " + where +
"UserActionTemplate.cc " + src );
148 Goofy::Shell(
"mv " + src + actName +
".temp " + src + +actName +
"Action.cc" );
149 Goofy::Shell(
"rm -f " + src +
"UserActionTemplate.cc" );