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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /intercoms/include/G4GenericMessenger.hh (Version 11.3.0) and /intercoms/include/G4GenericMessenger.hh (Version 11.0)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4GenericMessenger                              26 // G4GenericMessenger
 27 //                                                 27 //
 28 // Class description:                              28 // Class description:
 29 //                                                 29 //
 30 // A generic messenger class.                      30 // A generic messenger class.
 31                                                    31 
 32 // Author: P.Mato, CERN - 27 September 2012        32 // Author: P.Mato, CERN - 27 September 2012
 33 // -------------------------------------------     33 // --------------------------------------------------------------------
 34 #ifndef G4GenericMessenger_hh                      34 #ifndef G4GenericMessenger_hh
 35 #define G4GenericMessenger_hh 1                    35 #define G4GenericMessenger_hh 1
 36                                                    36 
 37 #include "G4AnyMethod.hh"                      <<  37 #include "G4UImessenger.hh"
                                                   >>  38 #include "G4UIcommand.hh"
 38 #include "G4AnyType.hh"                            39 #include "G4AnyType.hh"
                                                   >>  40 #include "G4AnyMethod.hh"
 39 #include "G4ApplicationState.hh"                   41 #include "G4ApplicationState.hh"
 40 #include "G4UIcommand.hh"                      << 
 41 #include "G4UImessenger.hh"                    << 
 42                                                    42 
 43 #include <map>                                     43 #include <map>
 44 #include <vector>                                  44 #include <vector>
 45                                                    45 
 46 class G4UIdirectory;                               46 class G4UIdirectory;
 47                                                    47 
 48 class G4GenericMessenger : public G4UImessenge     48 class G4GenericMessenger : public G4UImessenger
 49 {                                                  49 {
 50   public:                                          50   public:
 51     // Contructor                              << 
 52     G4GenericMessenger(void* obj, const G4Stri << 
 53                                                    51 
 54     // Destructor                              <<  52     G4GenericMessenger(void* obj, const G4String& dir = "",
 55     ~G4GenericMessenger() override;            <<  53                        const G4String& doc = "");
 56                                                <<  54       // Contructor
 57     // The concrete, but generic implementatio <<  55 
 58     G4String GetCurrentValue(G4UIcommand* comm <<  56     virtual ~G4GenericMessenger();
 59                                                <<  57       // Destructor
 60     // The concrete, generic  implementation o <<  58 
 61     // the string "newValue" to action.        <<  59     virtual G4String GetCurrentValue(G4UIcommand* command);
 62     void SetNewValue(G4UIcommand* command, G4S <<  60       // The concrete, but generic implementation of this method.
                                                   >>  61 
                                                   >>  62     virtual void SetNewValue(G4UIcommand* command, G4String newValue);
                                                   >>  63       // The concrete, generic  implementation of this method converts
                                                   >>  64       // the string "newValue" to action.
 63                                                    65 
 64   public:                                          66   public:
                                                   >>  67 
 65     struct Command                                 68     struct Command
 66     {                                              69     {
 67         enum UnitSpec                          <<  70       enum UnitSpec
 68         {                                      <<  71       {
 69           UnitCategory,                        <<  72         UnitCategory,
 70           UnitDefault                          <<  73         UnitDefault
 71         };                                     <<  74       };
 72         Command(G4UIcommand* cmd, const std::t <<  75       Command(G4UIcommand* cmd, const std::type_info& ti)
 73         Command() = default;                   <<  76         : command(cmd)
 74                                                <<  77         , type(&ti)
 75         Command& SetStates(G4ApplicationState  <<  78       {}
 76         {                                      <<  79       Command()
 77           command->AvailableForStates(s0);     <<  80       {}
 78           return *this;                        <<  81 
 79         }                                      <<  82       Command& SetStates(G4ApplicationState s0)
 80         Command& SetStates(G4ApplicationState  <<  83       {
 81         {                                      <<  84         command->AvailableForStates(s0);
 82           command->AvailableForStates(s0, s1); <<  85         return *this;
 83           return *this;                        <<  86       }
 84         }                                      <<  87       Command& SetStates(G4ApplicationState s0, G4ApplicationState s1)
 85         Command& SetStates(G4ApplicationState  <<  88       {
 86         {                                      <<  89         command->AvailableForStates(s0, s1);
 87           command->AvailableForStates(s0, s1,  <<  90         return *this;
 88           return *this;                        <<  91       }
 89         }                                      <<  92       Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
 90         Command& SetStates(G4ApplicationState  <<  93                          G4ApplicationState s2)
 91                            G4ApplicationState  <<  94       {
 92         {                                      <<  95         command->AvailableForStates(s0, s1, s2);
 93           command->AvailableForStates(s0, s1,  <<  96         return *this;
 94           return *this;                        <<  97       }
 95         }                                      <<  98       Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
 96         Command& SetStates(G4ApplicationState  <<  99                          G4ApplicationState s2, G4ApplicationState s3)
 97                            G4ApplicationState  << 100       {
 98         {                                      << 101         command->AvailableForStates(s0, s1, s2, s3);
 99           command->AvailableForStates(s0, s1,  << 102         return *this;
100           return *this;                        << 103       }
101         }                                      << 104       Command& SetStates(G4ApplicationState s0, G4ApplicationState s1,
102         Command& SetRange(const G4String& rang << 105                          G4ApplicationState s2, G4ApplicationState s3,
103         {                                      << 106                          G4ApplicationState s4)
104           command->SetRange(range.c_str());    << 107       {
105           return *this;                        << 108         command->AvailableForStates(s0, s1, s2, s3, s4);
106         }                                      << 109         return *this;
107         Command& SetGuidance(const G4String& s << 110       }
108         {                                      << 111       Command& SetRange(const G4String& range)
109           command->SetGuidance(s0);            << 112       {
110           return *this;                        << 113         command->SetRange(range.c_str());
111         }                                      << 114         return *this;
112         Command& SetUnit(const G4String&, Unit << 115       }
113         Command& SetUnitCategory(const G4Strin << 116       Command& SetGuidance(const G4String& s0)
114         Command& SetDefaultUnit(const G4String << 117       {
115         Command& SetParameterName(const G4Stri << 118         command->SetGuidance(s0);
116         Command& SetParameterName(G4int pIdx,  << 119         return *this;
117         Command& SetParameterName(const G4Stri << 120       }
118                                   G4bool = fal << 121       Command& SetUnit(const G4String&, UnitSpec = UnitDefault);
119         Command& SetDefaultValue(const G4Strin << 122       Command& SetUnitCategory(const G4String& u)
120         Command& SetDefaultValue(G4int pIdx, c << 123       {
121         Command& SetCandidates(const G4String& << 124         return SetUnit(u, UnitCategory);
122         Command& SetCandidates(G4int pIdx, con << 125       }
123         Command& SetToBeBroadcasted(G4bool s0) << 126       Command& SetDefaultUnit(const G4String& u)
124         {                                      << 127       {
125           command->SetToBeBroadcasted(s0);     << 128         return SetUnit(u, UnitDefault);
126           return *this;                        << 129       }
127         }                                      << 130       Command& SetParameterName(const G4String&, G4bool, G4bool = false);
128         Command& SetToBeFlushed(G4bool s0)     << 131       Command& SetParameterName(const G4String&, const G4String&, const G4String&, 
129         {                                      << 132                                 G4bool, G4bool = false);
130           command->SetToBeFlushed(s0);         << 133       Command& SetDefaultValue(const G4String&);
131           return *this;                        << 134       Command& SetCandidates(const G4String&);
132         }                                      << 135       Command& SetToBeBroadcasted(G4bool s0)
133         Command& SetWorkerThreadOnly(G4bool s0 << 136       {
134         {                                      << 137         command->SetToBeBroadcasted(s0);
135           command->SetWorkerThreadOnly(s0);    << 138         return *this;
136           return *this;                        << 139       }
137         }                                      << 140       Command& SetToBeFlushed(G4bool s0)
                                                   >> 141       {
                                                   >> 142         command->SetToBeFlushed(s0);
                                                   >> 143         return *this;
                                                   >> 144       }
                                                   >> 145       Command& SetWorkerThreadOnly(G4bool s0)
                                                   >> 146       {
                                                   >> 147         command->SetWorkerThreadOnly(s0);
                                                   >> 148         return *this;
                                                   >> 149       }
138                                                   150 
139         G4UIcommand* command = nullptr;        << 151       G4UIcommand* command = nullptr;
140         const std::type_info* type = nullptr;  << 152       const std::type_info* type = nullptr;
141     };                                            153     };
142                                                   154 
143     struct Property : public Command              155     struct Property : public Command
144     {                                             156     {
145         Property(const G4AnyType& var, G4UIcom << 157       Property(const G4AnyType& var, G4UIcommand* cmd)
146           : Command(cmd, var.TypeInfo()), vari << 158         : Command(cmd, var.TypeInfo())
147         {}                                     << 159         , variable(var)
148         Property() = default;                  << 160       {}
149         G4AnyType variable;                    << 161       Property() {}
                                                   >> 162       G4AnyType variable;
150     };                                            163     };
151                                                   164 
152     struct Method : public Command                165     struct Method : public Command
153     {                                             166     {
154         Method(const G4AnyMethod& fun, void* o << 167       Method(const G4AnyMethod& fun, void* obj, G4UIcommand* cmd)
155           : Command(cmd, fun.ArgType()), metho << 168         : Command(cmd, fun.ArgType())
156         {}                                     << 169         , method(fun)
157         Method() = default;                    << 170         , object(obj)
158         G4AnyMethod method;                    << 171       {}
159         void* object = nullptr;                << 172       Method()
                                                   >> 173       {}
                                                   >> 174       G4AnyMethod method;
                                                   >> 175       void* object = nullptr;
160     };                                            176     };
161                                                   177 
162     // Declare Methods                            178     // Declare Methods
163                                                   179 
164     Command& DeclareProperty(const G4String& n    180     Command& DeclareProperty(const G4String& name, const G4AnyType& variable,
165                              const G4String& d    181                              const G4String& doc = "");
166     Command& DeclarePropertyWithUnit(const G4S << 182     Command& DeclarePropertyWithUnit(const G4String& name,
167                                      const G4A << 183                                      const G4String& defaultUnit,
168     Command& DeclareMethod(const G4String& nam << 184                                      const G4AnyType& variable,
169     Command& DeclareMethodWithUnit(const G4Str << 185                                      const G4String& doc = "");
170                                    const G4Any << 186     Command& DeclareMethod(const G4String& name, const G4AnyMethod& fun,
                                                   >> 187                            const G4String& doc = "");
                                                   >> 188     Command& DeclareMethodWithUnit(const G4String& name,
                                                   >> 189                                    const G4String& defaultUnit,
                                                   >> 190                                    const G4AnyMethod& fun,
                                                   >> 191                                    const G4String& doc = "");
171     void SetDirectory(const G4String& dir) { d    192     void SetDirectory(const G4String& dir) { directory = dir; }
172     void SetGuidance(const G4String& s);          193     void SetGuidance(const G4String& s);
173     void Sort(G4bool val = true)                  194     void Sort(G4bool val = true)
174     {                                          << 195     { if(dircmd) dircmd->Sort(val); }
175       if (dircmd != nullptr) {                 << 
176         dircmd->Sort(val);                     << 
177       }                                        << 
178     }                                          << 
179                                                   196 
180   private:                                        197   private:
                                                   >> 198 
181     std::map<G4String, Property> properties;      199     std::map<G4String, Property> properties;
182     std::map<G4String, Method> methods;           200     std::map<G4String, Method> methods;
183     G4UIdirectory* dircmd = nullptr;              201     G4UIdirectory* dircmd = nullptr;
184     G4String directory;                           202     G4String directory;
185     void* object = nullptr;                       203     void* object = nullptr;
186 };                                                204 };
187                                                   205 
188 #endif                                            206 #endif
189                                                   207