36#define NewString(str) \
37 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
43 mainInteractor(nullptr),
44 secondaryLoopEnabled(true),
45 alreadyInSecondaryLoop(false),
47 parentInteractor(nullptr),
48 createdInteractor(nullptr),
49 creationString(nullptr)
58 if (argv !=
nullptr) {
59 for (
G4int argi = 0; argi < argc; ++argi) {
60 if (argv[argi] !=
nullptr)
free(argv[argi]);
70 secondaryLoopEnabled =
true;
71 alreadyInSecondaryLoop =
false;
72 exitSecondaryLoop = 0;
80 if (argv !=
nullptr) {
81 for (
G4int argi = 0; argi < argc; ++argi) {
82 if (argv[argi] !=
nullptr)
free(argv[argi]);
90 argv = (
char**)malloc(a_argc *
sizeof(
char*));
91 if (argv !=
nullptr) {
93 for (
G4int argi = 0; argi < a_argc; ++argi) {
94 argv[argi] = (
char*)
NewString(a_argv[argi]);
104 if (a_argc !=
nullptr) *a_argc = argc;
112 mainInteractor = a_main;
119 return mainInteractor;
126 secondaryLoopEnabled =
true;
133 secondaryLoopEnabled =
false;
140 if (a_dispatcher ==
nullptr)
return;
141 if (std::find(dispatchers.cbegin(), dispatchers.cend(), a_dispatcher) != dispatchers.cend())
143 dispatchers.push_back(a_dispatcher);
150 std::vector<G4DispatchFunction>::iterator it;
151 for (it = dispatchers.begin(); it != dispatchers.end(); ++it) {
152 if (*it == a_dispatcher) {
153 dispatchers.erase(it);
163 std::size_t dispatchern = dispatchers.size();
165 for (std::size_t count = 0; count < dispatchern; ++count) {
166 func = dispatchers[count];
167 if (func !=
nullptr) {
168 if (func(a_event))
return;
177 if (a_preAction ==
nullptr)
return;
178 if (std::find(preActions.cbegin(), preActions.cend(), a_preAction) != preActions.cend())
return;
179 preActions.push_back(a_preAction);
186 std::size_t preActionn = preActions.size();
187 for (std::size_t count = 0; count < preActionn; ++count) {
188 if (preActions[count] !=
nullptr) preActions[count]();
196 if (a_postAction ==
nullptr)
return;
197 if (std::find(postActions.cbegin(), postActions.cend(), a_postAction) != postActions.cend())
199 postActions.push_back(a_postAction);
206 std::size_t postActionn = postActions.size();
207 for (std::size_t count = 0; count < postActionn; ++count) {
208 if (postActions[count] !=
nullptr) postActions[count]();
218 if (! secondaryLoopEnabled)
return;
220 if (! alreadyInSecondaryLoop) {
221 G4cout <<
"------------------------------------------" <<
G4endl;
222 G4cout <<
"You have entered a viewer secondary X event loop." <<
G4endl;
223 G4cout <<
"Quit it with an 'Escape' viewer button" <<
G4endl;
224 alreadyInSecondaryLoop =
true;
225 exitSecondaryLoop = 0;
231 if (event ==
nullptr)
break;
233 if (exitSecondaryLoop != 0)
break;
244 if (! secondaryLoopEnabled)
return;
245 if (a_code == 0) a_code = 1;
246 exitSecondaryLoop = a_code;
247 alreadyInSecondaryLoop =
false;
254 return exitSecondaryLoop;
261 if (a_shell ==
nullptr)
return;
262 if (std::find(shells.cbegin(), shells.cend(), a_shell) != shells.cend())
return;
263 shells.push_back(a_shell);
270 std::vector<G4Interactor>::iterator it;
271 for (it = shells.begin(); it != shells.end(); ++it) {
272 if (*it == a_shell) {
283 parentInteractor = a_interactor;
290 return parentInteractor;
297 createdInteractor = a_interactor;
304 return createdInteractor;
311 creationString = a_string;
318 return creationString;
G4bool(*)(void *) G4DispatchFunction
void(*)() G4SecondaryLoopAction
G4GLOB_DLL std::ostream G4cout
void AddDispatcher(G4DispatchFunction)
char ** GetArguments(int *)
void SetCreatedInteractor(G4Interactor)
void SetMainInteractor(G4Interactor)
void AddSecondaryLoopPostAction(G4SecondaryLoopAction)
void SetParentInteractor(G4Interactor)
void EnableSecondaryLoop()
virtual void SecondaryLoop()
G4Interactor GetMainInteractor()
virtual ~G4VInteractorManager()
G4Interactor GetParentInteractor()
void DisableSecondaryLoop()
char * GetCreationString()
G4Interactor GetCreatedInteractor()
void SecondaryLoopPostActions()
int GetExitSecondaryLoopCode()
virtual void * GetEvent()=0
void SecondaryLoopPreActions()
void RemoveShell(G4Interactor)
void DispatchEvent(void *)
void RemoveDispatcher(G4DispatchFunction)
virtual G4bool Inited()=0
void AddSecondaryLoopPreAction(G4SecondaryLoopAction)
void SetCreationString(char *)
void SetArguments(int, char **)
void RequireExitSecondaryLoop(int)
void AddShell(G4Interactor)