G4BlockingList.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // class G4BlockingList
00030 //
00031 // Class description:
00032 //
00033 // A utility class responsible for (efficiently) maintaining a List 
00034 // of blocked volume numbers, with rapid `reset' operations.
00035 //
00036 // Notes:
00037 //
00038 // Implemented via a ValVector of ints: a tag value is used to set
00039 // the indices of blocked volumes. On reset the current tag value is
00040 // increased, so that the ValVector must only be zeroed when the
00041 // numerical range of the tag is used.
00042 
00043 // History:
00044 //
00045 // 24.7.96 P.Kent Separated from G4Navigator
00046 // --------------------------------------------------------------------
00047 #ifndef G4BLOCKINGLIST_HH
00048 #define G4BLOCKINGLIST_HH
00049 
00050 #include "G4Types.hh"
00051 #include <vector>
00052 
00053 const G4int kBlockingListMaxDefault = 500; // Block up to 511 daughters
00054                                            // initially
00055 const G4int kBlockingListStride = 128;
00056 const G4int kBlockTagNoMax = 2147483647;   // 2^31-1 maximum tag no may reach
00057 
00058 class G4BlockingList
00059 {
00060   public:  // with description
00061 
00062     G4BlockingList(G4int maxDefault=kBlockingListMaxDefault,
00063                    G4int stride=kBlockingListStride);
00064       // Create empty blocking List of default size and `stride' resize count.
00065 
00066     ~G4BlockingList();
00067       // Destructor. No operations.
00068 
00069     void Reset();
00070       // Efficiently `Reset' the blocking List, so that no volumes
00071       // are blocked [Advance tag number and only fully clear List
00072       // if tag max reached]
00073 
00074     void FullyReset();
00075       // Clear the blocking List and reset tag value [slow].
00076 
00077     void Enlarge(const G4int nv);
00078       // Enlarges blocking List if current size < nv, in units of stride.
00079       // Clears the new part of the List.
00080 
00081     G4int Length() const;
00082       // Returns the current length of the List. Note a length of 16
00083       // means volumes of indices between 0 & 15 inclusive may be blocked.
00084 
00085     void BlockVolume(const G4int v);
00086       // Block the volume number v.
00087       // Requires: 0<=v<Length().
00088 
00089     G4bool IsBlocked(const G4int v) const;
00090       // Return true if the volume number v is blocked, else false.
00091       // Requires: 0 <= v < Length().
00092 
00093   private:
00094 
00095     G4int fBlockTagNo, fStride;
00096       // Current blocked volume tag number.
00097 
00098     std::vector<G4int> fBlockingList; 
00099       // Blocked volumes: Elements with indices
00100       // corresponding to blocked volume set to fBlockTagNo.
00101 
00102 };
00103 
00104 #include "G4BlockingList.icc"
00105 
00106 #endif

Generated on Mon May 27 17:47:46 2013 for Geant4 by  doxygen 1.4.7