| [834] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | // $Id: G4VModelFactory.hh,v 1.6 2006/06/29 21:32:30 gunter Exp $
|
|---|
| [954] | 27 | // GEANT4 tag $Name: $
|
|---|
| [834] | 28 | //
|
|---|
| 29 | // Jane Tinslay, John Allison, Joseph Perl October 2005
|
|---|
| 30 | //
|
|---|
| 31 | // Class Description:
|
|---|
| 32 | // Abstract base class for model factories. Derived classes
|
|---|
| 33 | // must implement the Create method, creating a new model
|
|---|
| 34 | // and associated messengers.
|
|---|
| 35 | // Class Description - End:
|
|---|
| 36 |
|
|---|
| 37 | #ifndef G4VMODELFACTORY
|
|---|
| 38 | #define G4VMODELFACTORY
|
|---|
| 39 |
|
|---|
| 40 | #include "G4String.hh"
|
|---|
| 41 | #include <iostream>
|
|---|
| 42 | #include <utility>
|
|---|
| 43 | #include <vector>
|
|---|
| 44 |
|
|---|
| 45 | class G4UImessenger;
|
|---|
| 46 |
|
|---|
| 47 | template <class T>
|
|---|
| 48 | class G4VModelFactory {
|
|---|
| 49 |
|
|---|
| 50 | public: // With description
|
|---|
| 51 |
|
|---|
| 52 | typedef std::vector<G4UImessenger*> Messengers;
|
|---|
| 53 | typedef std::pair<T*, Messengers> ModelAndMessengers;
|
|---|
| 54 |
|
|---|
| 55 | G4VModelFactory(const G4String& name);
|
|---|
| 56 |
|
|---|
| 57 | virtual ~G4VModelFactory();
|
|---|
| 58 |
|
|---|
| 59 | G4String Name();
|
|---|
| 60 |
|
|---|
| 61 | virtual ModelAndMessengers Create(const G4String& placement, const G4String& modelName) = 0;
|
|---|
| 62 |
|
|---|
| 63 | void Print(std::ostream& ostr) const;
|
|---|
| 64 |
|
|---|
| 65 | private:
|
|---|
| 66 |
|
|---|
| 67 | G4String fName;
|
|---|
| 68 |
|
|---|
| 69 | };
|
|---|
| 70 |
|
|---|
| 71 | template <typename T>
|
|---|
| 72 | G4VModelFactory<T>::G4VModelFactory(const G4String& name)
|
|---|
| 73 | :fName(name)
|
|---|
| 74 | {}
|
|---|
| 75 |
|
|---|
| 76 | template <typename T>
|
|---|
| 77 | G4VModelFactory<T>::~G4VModelFactory() {}
|
|---|
| 78 |
|
|---|
| 79 | template <typename T>
|
|---|
| 80 | G4String
|
|---|
| 81 | G4VModelFactory<T>::Name()
|
|---|
| 82 | {
|
|---|
| 83 | return fName;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | template <typename T>
|
|---|
| 87 | void
|
|---|
| 88 | G4VModelFactory<T>::Print(std::ostream& ostr) const
|
|---|
| 89 | {
|
|---|
| 90 | ostr<<" "<<fName<<std::endl;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | #endif
|
|---|
| 94 |
|
|---|