-
Notifications
You must be signed in to change notification settings - Fork 0
/
gong.go
1718 lines (1503 loc) · 50.5 KB
/
gong.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// generated code - do not edit
package models
import (
"cmp"
"errors"
"fmt"
"math"
"slices"
"time"
"golang.org/x/exp/maps"
)
func __Gong__Abs(x int) int {
if x < 0 {
return -x
}
return x
}
// errUnkownEnum is returns when a value cannot match enum values
var errUnkownEnum = errors.New("unkown enum")
// needed to avoid when fmt package is not needed by generated code
var __dummy__fmt_variable fmt.Scanner
// idem for math package when not need by generated code
var __dummy_math_variable = math.E
// swagger:ignore
type __void any
// needed for creating set of instances in the stage
var __member __void
// GongStructInterface is the interface met by GongStructs
// It allows runtime reflexion of instances (without the hassle of the "reflect" package)
type GongStructInterface interface {
GetName() (res string)
// GetID() (res int)
// GetFields() (res []string)
// GetFieldStringValue(fieldName string) (res string)
}
// StageStruct enables storage of staged instances
// swagger:ignore
type StageStruct struct {
path string
// insertion point for definition of arrays registering instances
CivilianAirports map[*CivilianAirport]any
CivilianAirports_mapString map[string]*CivilianAirport
// insertion point for slice of pointers maps
OnAfterCivilianAirportCreateCallback OnAfterCreateInterface[CivilianAirport]
OnAfterCivilianAirportUpdateCallback OnAfterUpdateInterface[CivilianAirport]
OnAfterCivilianAirportDeleteCallback OnAfterDeleteInterface[CivilianAirport]
OnAfterCivilianAirportReadCallback OnAfterReadInterface[CivilianAirport]
Liners map[*Liner]any
Liners_mapString map[string]*Liner
// insertion point for slice of pointers maps
OnAfterLinerCreateCallback OnAfterCreateInterface[Liner]
OnAfterLinerUpdateCallback OnAfterUpdateInterface[Liner]
OnAfterLinerDeleteCallback OnAfterDeleteInterface[Liner]
OnAfterLinerReadCallback OnAfterReadInterface[Liner]
Messages map[*Message]any
Messages_mapString map[string]*Message
// insertion point for slice of pointers maps
OnAfterMessageCreateCallback OnAfterCreateInterface[Message]
OnAfterMessageUpdateCallback OnAfterUpdateInterface[Message]
OnAfterMessageDeleteCallback OnAfterDeleteInterface[Message]
OnAfterMessageReadCallback OnAfterReadInterface[Message]
OpsLines map[*OpsLine]any
OpsLines_mapString map[string]*OpsLine
// insertion point for slice of pointers maps
OnAfterOpsLineCreateCallback OnAfterCreateInterface[OpsLine]
OnAfterOpsLineUpdateCallback OnAfterUpdateInterface[OpsLine]
OnAfterOpsLineDeleteCallback OnAfterDeleteInterface[OpsLine]
OnAfterOpsLineReadCallback OnAfterReadInterface[OpsLine]
Radars map[*Radar]any
Radars_mapString map[string]*Radar
// insertion point for slice of pointers maps
OnAfterRadarCreateCallback OnAfterCreateInterface[Radar]
OnAfterRadarUpdateCallback OnAfterUpdateInterface[Radar]
OnAfterRadarDeleteCallback OnAfterDeleteInterface[Radar]
OnAfterRadarReadCallback OnAfterReadInterface[Radar]
Satellites map[*Satellite]any
Satellites_mapString map[string]*Satellite
// insertion point for slice of pointers maps
OnAfterSatelliteCreateCallback OnAfterCreateInterface[Satellite]
OnAfterSatelliteUpdateCallback OnAfterUpdateInterface[Satellite]
OnAfterSatelliteDeleteCallback OnAfterDeleteInterface[Satellite]
OnAfterSatelliteReadCallback OnAfterReadInterface[Satellite]
Scenarios map[*Scenario]any
Scenarios_mapString map[string]*Scenario
// insertion point for slice of pointers maps
OnAfterScenarioCreateCallback OnAfterCreateInterface[Scenario]
OnAfterScenarioUpdateCallback OnAfterUpdateInterface[Scenario]
OnAfterScenarioDeleteCallback OnAfterDeleteInterface[Scenario]
OnAfterScenarioReadCallback OnAfterReadInterface[Scenario]
AllModelsStructCreateCallback AllModelsStructCreateInterface
AllModelsStructDeleteCallback AllModelsStructDeleteInterface
BackRepo BackRepoInterface
// if set will be called before each commit to the back repo
OnInitCommitCallback OnInitCommitInterface
OnInitCommitFromFrontCallback OnInitCommitInterface
OnInitCommitFromBackCallback OnInitCommitInterface
// store the number of instance per gongstruct
Map_GongStructName_InstancesNb map[string]int
// store meta package import
MetaPackageImportPath string
MetaPackageImportAlias string
// to be removed after fix of [issue](https://github.com/golang/go/issues/57559)
// map to enable docLink renaming when an identifier is renamed
Map_DocLink_Renaming map[string]GONG__Identifier
// the to be removed stops here
}
func (stage *StageStruct) GetType() string {
return "github.com/fullstack-lang/gongfly/go/models"
}
type GONG__Identifier struct {
Ident string
Type GONG__ExpressionType
}
type OnInitCommitInterface interface {
BeforeCommit(stage *StageStruct)
}
// OnAfterCreateInterface callback when an instance is updated from the front
type OnAfterCreateInterface[Type Gongstruct] interface {
OnAfterCreate(stage *StageStruct,
instance *Type)
}
// OnAfterReadInterface callback when an instance is updated from the front
type OnAfterReadInterface[Type Gongstruct] interface {
OnAfterRead(stage *StageStruct,
instance *Type)
}
// OnAfterUpdateInterface callback when an instance is updated from the front
type OnAfterUpdateInterface[Type Gongstruct] interface {
OnAfterUpdate(stage *StageStruct, old, new *Type)
}
// OnAfterDeleteInterface callback when an instance is updated from the front
type OnAfterDeleteInterface[Type Gongstruct] interface {
OnAfterDelete(stage *StageStruct,
staged, front *Type)
}
type BackRepoInterface interface {
Commit(stage *StageStruct)
Checkout(stage *StageStruct)
Backup(stage *StageStruct, dirPath string)
Restore(stage *StageStruct, dirPath string)
BackupXL(stage *StageStruct, dirPath string)
RestoreXL(stage *StageStruct, dirPath string)
// insertion point for Commit and Checkout signatures
CommitCivilianAirport(civilianairport *CivilianAirport)
CheckoutCivilianAirport(civilianairport *CivilianAirport)
CommitLiner(liner *Liner)
CheckoutLiner(liner *Liner)
CommitMessage(message *Message)
CheckoutMessage(message *Message)
CommitOpsLine(opsline *OpsLine)
CheckoutOpsLine(opsline *OpsLine)
CommitRadar(radar *Radar)
CheckoutRadar(radar *Radar)
CommitSatellite(satellite *Satellite)
CheckoutSatellite(satellite *Satellite)
CommitScenario(scenario *Scenario)
CheckoutScenario(scenario *Scenario)
GetLastCommitFromBackNb() uint
GetLastPushFromFrontNb() uint
}
func NewStage(path string) (stage *StageStruct) {
stage = &StageStruct{ // insertion point for array initiatialisation
CivilianAirports: make(map[*CivilianAirport]any),
CivilianAirports_mapString: make(map[string]*CivilianAirport),
Liners: make(map[*Liner]any),
Liners_mapString: make(map[string]*Liner),
Messages: make(map[*Message]any),
Messages_mapString: make(map[string]*Message),
OpsLines: make(map[*OpsLine]any),
OpsLines_mapString: make(map[string]*OpsLine),
Radars: make(map[*Radar]any),
Radars_mapString: make(map[string]*Radar),
Satellites: make(map[*Satellite]any),
Satellites_mapString: make(map[string]*Satellite),
Scenarios: make(map[*Scenario]any),
Scenarios_mapString: make(map[string]*Scenario),
// end of insertion point
Map_GongStructName_InstancesNb: make(map[string]int),
path: path,
// to be removed after fix of [issue](https://github.com/golang/go/issues/57559)
Map_DocLink_Renaming: make(map[string]GONG__Identifier),
// the to be removed stops here
}
return
}
func (stage *StageStruct) GetPath() string {
return stage.path
}
func (stage *StageStruct) CommitWithSuspendedCallbacks() {
tmp := stage.OnInitCommitFromBackCallback
stage.OnInitCommitFromBackCallback = nil
stage.Commit()
stage.OnInitCommitFromBackCallback = tmp
}
func (stage *StageStruct) Commit() {
stage.ComputeReverseMaps()
if stage.BackRepo != nil {
stage.BackRepo.Commit(stage)
}
// insertion point for computing the map of number of instances per gongstruct
stage.Map_GongStructName_InstancesNb["CivilianAirport"] = len(stage.CivilianAirports)
stage.Map_GongStructName_InstancesNb["Liner"] = len(stage.Liners)
stage.Map_GongStructName_InstancesNb["Message"] = len(stage.Messages)
stage.Map_GongStructName_InstancesNb["OpsLine"] = len(stage.OpsLines)
stage.Map_GongStructName_InstancesNb["Radar"] = len(stage.Radars)
stage.Map_GongStructName_InstancesNb["Satellite"] = len(stage.Satellites)
stage.Map_GongStructName_InstancesNb["Scenario"] = len(stage.Scenarios)
}
func (stage *StageStruct) Checkout() {
if stage.BackRepo != nil {
stage.BackRepo.Checkout(stage)
}
stage.ComputeReverseMaps()
// insertion point for computing the map of number of instances per gongstruct
stage.Map_GongStructName_InstancesNb["CivilianAirport"] = len(stage.CivilianAirports)
stage.Map_GongStructName_InstancesNb["Liner"] = len(stage.Liners)
stage.Map_GongStructName_InstancesNb["Message"] = len(stage.Messages)
stage.Map_GongStructName_InstancesNb["OpsLine"] = len(stage.OpsLines)
stage.Map_GongStructName_InstancesNb["Radar"] = len(stage.Radars)
stage.Map_GongStructName_InstancesNb["Satellite"] = len(stage.Satellites)
stage.Map_GongStructName_InstancesNb["Scenario"] = len(stage.Scenarios)
}
// backup generates backup files in the dirPath
func (stage *StageStruct) Backup(dirPath string) {
if stage.BackRepo != nil {
stage.BackRepo.Backup(stage, dirPath)
}
}
// Restore resets Stage & BackRepo and restores their content from the restore files in dirPath
func (stage *StageStruct) Restore(dirPath string) {
if stage.BackRepo != nil {
stage.BackRepo.Restore(stage, dirPath)
}
}
// backup generates backup files in the dirPath
func (stage *StageStruct) BackupXL(dirPath string) {
if stage.BackRepo != nil {
stage.BackRepo.BackupXL(stage, dirPath)
}
}
// Restore resets Stage & BackRepo and restores their content from the restore files in dirPath
func (stage *StageStruct) RestoreXL(dirPath string) {
if stage.BackRepo != nil {
stage.BackRepo.RestoreXL(stage, dirPath)
}
}
// insertion point for cumulative sub template with model space calls
// Stage puts civilianairport to the model stage
func (civilianairport *CivilianAirport) Stage(stage *StageStruct) *CivilianAirport {
stage.CivilianAirports[civilianairport] = __member
stage.CivilianAirports_mapString[civilianairport.Name] = civilianairport
return civilianairport
}
// Unstage removes civilianairport off the model stage
func (civilianairport *CivilianAirport) Unstage(stage *StageStruct) *CivilianAirport {
delete(stage.CivilianAirports, civilianairport)
delete(stage.CivilianAirports_mapString, civilianairport.Name)
return civilianairport
}
// UnstageVoid removes civilianairport off the model stage
func (civilianairport *CivilianAirport) UnstageVoid(stage *StageStruct) {
delete(stage.CivilianAirports, civilianairport)
delete(stage.CivilianAirports_mapString, civilianairport.Name)
}
// commit civilianairport to the back repo (if it is already staged)
func (civilianairport *CivilianAirport) Commit(stage *StageStruct) *CivilianAirport {
if _, ok := stage.CivilianAirports[civilianairport]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitCivilianAirport(civilianairport)
}
}
return civilianairport
}
func (civilianairport *CivilianAirport) CommitVoid(stage *StageStruct) {
civilianairport.Commit(stage)
}
// Checkout civilianairport to the back repo (if it is already staged)
func (civilianairport *CivilianAirport) Checkout(stage *StageStruct) *CivilianAirport {
if _, ok := stage.CivilianAirports[civilianairport]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutCivilianAirport(civilianairport)
}
}
return civilianairport
}
// for satisfaction of GongStruct interface
func (civilianairport *CivilianAirport) GetName() (res string) {
return civilianairport.Name
}
// Stage puts liner to the model stage
func (liner *Liner) Stage(stage *StageStruct) *Liner {
stage.Liners[liner] = __member
stage.Liners_mapString[liner.Name] = liner
return liner
}
// Unstage removes liner off the model stage
func (liner *Liner) Unstage(stage *StageStruct) *Liner {
delete(stage.Liners, liner)
delete(stage.Liners_mapString, liner.Name)
return liner
}
// UnstageVoid removes liner off the model stage
func (liner *Liner) UnstageVoid(stage *StageStruct) {
delete(stage.Liners, liner)
delete(stage.Liners_mapString, liner.Name)
}
// commit liner to the back repo (if it is already staged)
func (liner *Liner) Commit(stage *StageStruct) *Liner {
if _, ok := stage.Liners[liner]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitLiner(liner)
}
}
return liner
}
func (liner *Liner) CommitVoid(stage *StageStruct) {
liner.Commit(stage)
}
// Checkout liner to the back repo (if it is already staged)
func (liner *Liner) Checkout(stage *StageStruct) *Liner {
if _, ok := stage.Liners[liner]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutLiner(liner)
}
}
return liner
}
// for satisfaction of GongStruct interface
func (liner *Liner) GetName() (res string) {
return liner.Name
}
// Stage puts message to the model stage
func (message *Message) Stage(stage *StageStruct) *Message {
stage.Messages[message] = __member
stage.Messages_mapString[message.Name] = message
return message
}
// Unstage removes message off the model stage
func (message *Message) Unstage(stage *StageStruct) *Message {
delete(stage.Messages, message)
delete(stage.Messages_mapString, message.Name)
return message
}
// UnstageVoid removes message off the model stage
func (message *Message) UnstageVoid(stage *StageStruct) {
delete(stage.Messages, message)
delete(stage.Messages_mapString, message.Name)
}
// commit message to the back repo (if it is already staged)
func (message *Message) Commit(stage *StageStruct) *Message {
if _, ok := stage.Messages[message]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitMessage(message)
}
}
return message
}
func (message *Message) CommitVoid(stage *StageStruct) {
message.Commit(stage)
}
// Checkout message to the back repo (if it is already staged)
func (message *Message) Checkout(stage *StageStruct) *Message {
if _, ok := stage.Messages[message]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutMessage(message)
}
}
return message
}
// for satisfaction of GongStruct interface
func (message *Message) GetName() (res string) {
return message.Name
}
// Stage puts opsline to the model stage
func (opsline *OpsLine) Stage(stage *StageStruct) *OpsLine {
stage.OpsLines[opsline] = __member
stage.OpsLines_mapString[opsline.Name] = opsline
return opsline
}
// Unstage removes opsline off the model stage
func (opsline *OpsLine) Unstage(stage *StageStruct) *OpsLine {
delete(stage.OpsLines, opsline)
delete(stage.OpsLines_mapString, opsline.Name)
return opsline
}
// UnstageVoid removes opsline off the model stage
func (opsline *OpsLine) UnstageVoid(stage *StageStruct) {
delete(stage.OpsLines, opsline)
delete(stage.OpsLines_mapString, opsline.Name)
}
// commit opsline to the back repo (if it is already staged)
func (opsline *OpsLine) Commit(stage *StageStruct) *OpsLine {
if _, ok := stage.OpsLines[opsline]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitOpsLine(opsline)
}
}
return opsline
}
func (opsline *OpsLine) CommitVoid(stage *StageStruct) {
opsline.Commit(stage)
}
// Checkout opsline to the back repo (if it is already staged)
func (opsline *OpsLine) Checkout(stage *StageStruct) *OpsLine {
if _, ok := stage.OpsLines[opsline]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutOpsLine(opsline)
}
}
return opsline
}
// for satisfaction of GongStruct interface
func (opsline *OpsLine) GetName() (res string) {
return opsline.Name
}
// Stage puts radar to the model stage
func (radar *Radar) Stage(stage *StageStruct) *Radar {
stage.Radars[radar] = __member
stage.Radars_mapString[radar.Name] = radar
return radar
}
// Unstage removes radar off the model stage
func (radar *Radar) Unstage(stage *StageStruct) *Radar {
delete(stage.Radars, radar)
delete(stage.Radars_mapString, radar.Name)
return radar
}
// UnstageVoid removes radar off the model stage
func (radar *Radar) UnstageVoid(stage *StageStruct) {
delete(stage.Radars, radar)
delete(stage.Radars_mapString, radar.Name)
}
// commit radar to the back repo (if it is already staged)
func (radar *Radar) Commit(stage *StageStruct) *Radar {
if _, ok := stage.Radars[radar]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitRadar(radar)
}
}
return radar
}
func (radar *Radar) CommitVoid(stage *StageStruct) {
radar.Commit(stage)
}
// Checkout radar to the back repo (if it is already staged)
func (radar *Radar) Checkout(stage *StageStruct) *Radar {
if _, ok := stage.Radars[radar]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutRadar(radar)
}
}
return radar
}
// for satisfaction of GongStruct interface
func (radar *Radar) GetName() (res string) {
return radar.Name
}
// Stage puts satellite to the model stage
func (satellite *Satellite) Stage(stage *StageStruct) *Satellite {
stage.Satellites[satellite] = __member
stage.Satellites_mapString[satellite.Name] = satellite
return satellite
}
// Unstage removes satellite off the model stage
func (satellite *Satellite) Unstage(stage *StageStruct) *Satellite {
delete(stage.Satellites, satellite)
delete(stage.Satellites_mapString, satellite.Name)
return satellite
}
// UnstageVoid removes satellite off the model stage
func (satellite *Satellite) UnstageVoid(stage *StageStruct) {
delete(stage.Satellites, satellite)
delete(stage.Satellites_mapString, satellite.Name)
}
// commit satellite to the back repo (if it is already staged)
func (satellite *Satellite) Commit(stage *StageStruct) *Satellite {
if _, ok := stage.Satellites[satellite]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitSatellite(satellite)
}
}
return satellite
}
func (satellite *Satellite) CommitVoid(stage *StageStruct) {
satellite.Commit(stage)
}
// Checkout satellite to the back repo (if it is already staged)
func (satellite *Satellite) Checkout(stage *StageStruct) *Satellite {
if _, ok := stage.Satellites[satellite]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutSatellite(satellite)
}
}
return satellite
}
// for satisfaction of GongStruct interface
func (satellite *Satellite) GetName() (res string) {
return satellite.Name
}
// Stage puts scenario to the model stage
func (scenario *Scenario) Stage(stage *StageStruct) *Scenario {
stage.Scenarios[scenario] = __member
stage.Scenarios_mapString[scenario.Name] = scenario
return scenario
}
// Unstage removes scenario off the model stage
func (scenario *Scenario) Unstage(stage *StageStruct) *Scenario {
delete(stage.Scenarios, scenario)
delete(stage.Scenarios_mapString, scenario.Name)
return scenario
}
// UnstageVoid removes scenario off the model stage
func (scenario *Scenario) UnstageVoid(stage *StageStruct) {
delete(stage.Scenarios, scenario)
delete(stage.Scenarios_mapString, scenario.Name)
}
// commit scenario to the back repo (if it is already staged)
func (scenario *Scenario) Commit(stage *StageStruct) *Scenario {
if _, ok := stage.Scenarios[scenario]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CommitScenario(scenario)
}
}
return scenario
}
func (scenario *Scenario) CommitVoid(stage *StageStruct) {
scenario.Commit(stage)
}
// Checkout scenario to the back repo (if it is already staged)
func (scenario *Scenario) Checkout(stage *StageStruct) *Scenario {
if _, ok := stage.Scenarios[scenario]; ok {
if stage.BackRepo != nil {
stage.BackRepo.CheckoutScenario(scenario)
}
}
return scenario
}
// for satisfaction of GongStruct interface
func (scenario *Scenario) GetName() (res string) {
return scenario.Name
}
// swagger:ignore
type AllModelsStructCreateInterface interface { // insertion point for Callbacks on creation
CreateORMCivilianAirport(CivilianAirport *CivilianAirport)
CreateORMLiner(Liner *Liner)
CreateORMMessage(Message *Message)
CreateORMOpsLine(OpsLine *OpsLine)
CreateORMRadar(Radar *Radar)
CreateORMSatellite(Satellite *Satellite)
CreateORMScenario(Scenario *Scenario)
}
type AllModelsStructDeleteInterface interface { // insertion point for Callbacks on deletion
DeleteORMCivilianAirport(CivilianAirport *CivilianAirport)
DeleteORMLiner(Liner *Liner)
DeleteORMMessage(Message *Message)
DeleteORMOpsLine(OpsLine *OpsLine)
DeleteORMRadar(Radar *Radar)
DeleteORMSatellite(Satellite *Satellite)
DeleteORMScenario(Scenario *Scenario)
}
func (stage *StageStruct) Reset() { // insertion point for array reset
stage.CivilianAirports = make(map[*CivilianAirport]any)
stage.CivilianAirports_mapString = make(map[string]*CivilianAirport)
stage.Liners = make(map[*Liner]any)
stage.Liners_mapString = make(map[string]*Liner)
stage.Messages = make(map[*Message]any)
stage.Messages_mapString = make(map[string]*Message)
stage.OpsLines = make(map[*OpsLine]any)
stage.OpsLines_mapString = make(map[string]*OpsLine)
stage.Radars = make(map[*Radar]any)
stage.Radars_mapString = make(map[string]*Radar)
stage.Satellites = make(map[*Satellite]any)
stage.Satellites_mapString = make(map[string]*Satellite)
stage.Scenarios = make(map[*Scenario]any)
stage.Scenarios_mapString = make(map[string]*Scenario)
}
func (stage *StageStruct) Nil() { // insertion point for array nil
stage.CivilianAirports = nil
stage.CivilianAirports_mapString = nil
stage.Liners = nil
stage.Liners_mapString = nil
stage.Messages = nil
stage.Messages_mapString = nil
stage.OpsLines = nil
stage.OpsLines_mapString = nil
stage.Radars = nil
stage.Radars_mapString = nil
stage.Satellites = nil
stage.Satellites_mapString = nil
stage.Scenarios = nil
stage.Scenarios_mapString = nil
}
func (stage *StageStruct) Unstage() { // insertion point for array nil
for civilianairport := range stage.CivilianAirports {
civilianairport.Unstage(stage)
}
for liner := range stage.Liners {
liner.Unstage(stage)
}
for message := range stage.Messages {
message.Unstage(stage)
}
for opsline := range stage.OpsLines {
opsline.Unstage(stage)
}
for radar := range stage.Radars {
radar.Unstage(stage)
}
for satellite := range stage.Satellites {
satellite.Unstage(stage)
}
for scenario := range stage.Scenarios {
scenario.Unstage(stage)
}
}
// Gongstruct is the type parameter for generated generic function that allows
// - access to staged instances
// - navigation between staged instances by going backward association links between gongstruct
// - full refactoring of Gongstruct identifiers / fields
type Gongstruct interface {
// insertion point for generic types
CivilianAirport | Liner | Message | OpsLine | Radar | Satellite | Scenario
}
type GongtructBasicField interface {
int | float64 | bool | string | time.Time | time.Duration
}
// Gongstruct is the type parameter for generated generic function that allows
// - access to staged instances
// - navigation between staged instances by going backward association links between gongstruct
// - full refactoring of Gongstruct identifiers / fields
type PointerToGongstruct interface {
// insertion point for generic types
*CivilianAirport | *Liner | *Message | *OpsLine | *Radar | *Satellite | *Scenario
GetName() string
CommitVoid(*StageStruct)
UnstageVoid(stage *StageStruct)
}
func CompareGongstructByName[T PointerToGongstruct](a, b T) int {
return cmp.Compare(a.GetName(), b.GetName())
}
func SortGongstructSetByName[T PointerToGongstruct](set map[T]any) (sortedSlice []T) {
sortedSlice = maps.Keys(set)
slices.SortFunc(sortedSlice, CompareGongstructByName)
return
}
func GetGongstrucsSorted[T PointerToGongstruct](stage *StageStruct) (sortedSlice []T) {
set := GetGongstructInstancesSetFromPointerType[T](stage)
sortedSlice = SortGongstructSetByName(*set)
return
}
type GongstructSet interface {
map[any]any |
// insertion point for generic types
map[*CivilianAirport]any |
map[*Liner]any |
map[*Message]any |
map[*OpsLine]any |
map[*Radar]any |
map[*Satellite]any |
map[*Scenario]any |
map[*any]any // because go does not support an extra "|" at the end of type specifications
}
type GongstructMapString interface {
map[any]any |
// insertion point for generic types
map[string]*CivilianAirport |
map[string]*Liner |
map[string]*Message |
map[string]*OpsLine |
map[string]*Radar |
map[string]*Satellite |
map[string]*Scenario |
map[*any]any // because go does not support an extra "|" at the end of type specifications
}
// GongGetSet returns the set staged GongstructType instances
// it is usefull because it allows refactoring of gong struct identifier
func GongGetSet[Type GongstructSet](stage *StageStruct) *Type {
var ret Type
switch any(ret).(type) {
// insertion point for generic get functions
case map[*CivilianAirport]any:
return any(&stage.CivilianAirports).(*Type)
case map[*Liner]any:
return any(&stage.Liners).(*Type)
case map[*Message]any:
return any(&stage.Messages).(*Type)
case map[*OpsLine]any:
return any(&stage.OpsLines).(*Type)
case map[*Radar]any:
return any(&stage.Radars).(*Type)
case map[*Satellite]any:
return any(&stage.Satellites).(*Type)
case map[*Scenario]any:
return any(&stage.Scenarios).(*Type)
default:
return nil
}
}
// GongGetMap returns the map of staged GongstructType instances
// it is usefull because it allows refactoring of gong struct identifier
func GongGetMap[Type GongstructMapString](stage *StageStruct) *Type {
var ret Type
switch any(ret).(type) {
// insertion point for generic get functions
case map[string]*CivilianAirport:
return any(&stage.CivilianAirports_mapString).(*Type)
case map[string]*Liner:
return any(&stage.Liners_mapString).(*Type)
case map[string]*Message:
return any(&stage.Messages_mapString).(*Type)
case map[string]*OpsLine:
return any(&stage.OpsLines_mapString).(*Type)
case map[string]*Radar:
return any(&stage.Radars_mapString).(*Type)
case map[string]*Satellite:
return any(&stage.Satellites_mapString).(*Type)
case map[string]*Scenario:
return any(&stage.Scenarios_mapString).(*Type)
default:
return nil
}
}
// GetGongstructInstancesSet returns the set staged GongstructType instances
// it is usefull because it allows refactoring of gongstruct identifier
func GetGongstructInstancesSet[Type Gongstruct](stage *StageStruct) *map[*Type]any {
var ret Type
switch any(ret).(type) {
// insertion point for generic get functions
case CivilianAirport:
return any(&stage.CivilianAirports).(*map[*Type]any)
case Liner:
return any(&stage.Liners).(*map[*Type]any)
case Message:
return any(&stage.Messages).(*map[*Type]any)
case OpsLine:
return any(&stage.OpsLines).(*map[*Type]any)
case Radar:
return any(&stage.Radars).(*map[*Type]any)
case Satellite:
return any(&stage.Satellites).(*map[*Type]any)
case Scenario:
return any(&stage.Scenarios).(*map[*Type]any)
default:
return nil
}
}
// GetGongstructInstancesSetFromPointerType returns the set staged GongstructType instances
// it is usefull because it allows refactoring of gongstruct identifier
func GetGongstructInstancesSetFromPointerType[Type PointerToGongstruct](stage *StageStruct) *map[Type]any {
var ret Type
switch any(ret).(type) {
// insertion point for generic get functions
case *CivilianAirport:
return any(&stage.CivilianAirports).(*map[Type]any)
case *Liner:
return any(&stage.Liners).(*map[Type]any)
case *Message:
return any(&stage.Messages).(*map[Type]any)
case *OpsLine:
return any(&stage.OpsLines).(*map[Type]any)
case *Radar:
return any(&stage.Radars).(*map[Type]any)
case *Satellite:
return any(&stage.Satellites).(*map[Type]any)
case *Scenario:
return any(&stage.Scenarios).(*map[Type]any)
default:
return nil
}
}
// GetGongstructInstancesMap returns the map of staged GongstructType instances
// it is usefull because it allows refactoring of gong struct identifier
func GetGongstructInstancesMap[Type Gongstruct](stage *StageStruct) *map[string]*Type {
var ret Type
switch any(ret).(type) {
// insertion point for generic get functions
case CivilianAirport:
return any(&stage.CivilianAirports_mapString).(*map[string]*Type)
case Liner:
return any(&stage.Liners_mapString).(*map[string]*Type)
case Message:
return any(&stage.Messages_mapString).(*map[string]*Type)
case OpsLine:
return any(&stage.OpsLines_mapString).(*map[string]*Type)
case Radar:
return any(&stage.Radars_mapString).(*map[string]*Type)
case Satellite:
return any(&stage.Satellites_mapString).(*map[string]*Type)
case Scenario:
return any(&stage.Scenarios_mapString).(*map[string]*Type)
default:
return nil
}
}
// GetAssociationName is a generic function that returns an instance of Type
// where each association is filled with an instance whose name is the name of the association
//
// This function can be handy for generating navigation function that are refactorable
func GetAssociationName[Type Gongstruct]() *Type {
var ret Type
switch any(ret).(type) {
// insertion point for instance with special fields
case CivilianAirport:
return any(&CivilianAirport{
// Initialisation of associations
}).(*Type)
case Liner:
return any(&Liner{
// Initialisation of associations
// field is initialized with an instance of OpsLine with the name of the field
ReporingLine: &OpsLine{Name: "ReporingLine"},
}).(*Type)
case Message:
return any(&Message{
// Initialisation of associations
}).(*Type)
case OpsLine:
return any(&OpsLine{
// Initialisation of associations
// field is initialized with an instance of Scenario with the name of the field
Scenario: &Scenario{Name: "Scenario"},
}).(*Type)