// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // $Id$ // // Generic model manager. Manages models, associated // factories, messengers, command placement etc // // Jane Tinslay, March 2006 // #ifndef G4VISMODELMANAGER_HH #define G4VISMODELMANAGER_HH #include "G4UImessenger.hh" #include "G4VisCommandModelCreate.hh" #include "G4VisListManager.hh" #include "G4VModelFactory.hh" #include template class G4VisModelManager { public: // With description // Useful typedef's typedef G4VisListManager List; typedef G4VModelFactory Factory; G4VisModelManager(const G4String&); virtual ~G4VisModelManager(); // Registration methods void Register(Model*); void Register(Factory*); // Change/Retrieve "Current" object void SetCurrent(const G4String&); const Model* Current() const; // Command placement G4String Placement() const; // Print factory and model data void Print(std::ostream& ostr, const G4String& name="") const; // Accessors const List* ListManager() const; const std::vector& FactoryList() const; private: // Private copy constructor and assigment operator - copying and // assignment not allowed. Keeps Coverity happy. G4VisModelManager (const G4VisModelManager&); G4VisModelManager& operator = (const G4VisModelManager&); // Data members G4String fPlacement; List* fpModelList; std::vector fFactoryList; std::vector fMessengerList; }; template G4VisModelManager::G4VisModelManager(const G4String& placement) :fPlacement(placement) ,fpModelList(new List) {} template G4VisModelManager::~G4VisModelManager() { // Cleanup std::vector::iterator iterMsgr = fMessengerList.begin(); while (iterMsgr != fMessengerList.end()) { delete *iterMsgr; iterMsgr++; } typename std::vector::iterator iterFactory = fFactoryList.begin(); while (iterFactory != fFactoryList.end()) { delete *iterFactory; iterFactory++; } delete fpModelList; } template void G4VisModelManager::Register(Model* model) { fpModelList->Register(model); } template void G4VisModelManager::Register(Factory* factory) { // Assume ownership fFactoryList.push_back(factory); // Generate "create" command for this factory fMessengerList.push_back(new G4VisCommandModelCreate(factory, fPlacement)); } template void G4VisModelManager::SetCurrent(const G4String& model) { fpModelList->SetCurrent(model); } template const Model* G4VisModelManager::Current() const { return fpModelList->Current(); } template G4String G4VisModelManager::Placement() const { return fPlacement; } template void G4VisModelManager::Print(std::ostream& ostr, const G4String& name) const { ostr<<"Registered model factories:"<::const_iterator iter = fFactoryList.begin(); while (iter != fFactoryList.end()) { (*iter)->Print(ostr); iter++; } if (0 == fFactoryList.size()) ostr<<" None"<Print(ostr, name); } template const G4VisListManager* G4VisModelManager::ListManager() const { return fpModelList; } template const std::vector*>& G4VisModelManager::FactoryList() const { return fFactoryList; } #endif