LCOV - code coverage report
Current view: top level - MUON/MUONcore - AliMUON1DMap.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 24 40 60.0 %
Date: 2016-06-14 17:26:59 Functions: 11 19 57.9 %

          Line data    Source code
       1             : /**************************************************************************
       2             : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             : *                                                                        *
       4             : * Author: The ALICE Off-line Project.                                    *
       5             : * Contributors are mentioned in the code where appropriate.              *
       6             : *                                                                        *
       7             : * Permission to use, copy, modify and distribute this software and its   *
       8             : * documentation strictly for non-commercial purposes is hereby granted   *
       9             : * without fee, provided that the above copyright notice appears in all   *
      10             : * copies and that both the copyright notice and this permission notice   *
      11             : * appear in the supporting documentation. The authors make no claims     *
      12             : * about the suitability of this software for any purpose. It is          *
      13             : * provided "as is" without express or implied warranty.                  *
      14             : **************************************************************************/
      15             : 
      16             : // $Id$
      17             : 
      18             : #include "AliMUON1DMap.h"
      19             : #include "AliMpExMap.h"
      20             : #include "AliMpExMapIterator.h"
      21             : 
      22             : #include "AliLog.h"
      23             : 
      24             : //-----------------------------------------------------------------------------
      25             : /// \class AliMUON1DMap
      26             : /// This class is simply a wrapper to an AliMpExMap, offering in addition a
      27             : /// control over the replacement policy when you add
      28             : /// something to it.
      29             : ///
      30             : /// \author Laurent Aphecetche
      31             : //-----------------------------------------------------------------------------
      32             : 
      33             : /// \cond CLASSIMP
      34          18 : ClassImp(AliMUON1DMap)
      35             : /// \endcond
      36             : 
      37             : //_____________________________________________________________________________
      38             : AliMUON1DMap::AliMUON1DMap(TRootIOCtor*)
      39           2 : : AliMUONVStore(),
      40           2 : fMap(0x0)
      41          10 : {
      42             :   /// I/O ctor
      43             :   
      44           4 : }
      45             : 
      46             : //_____________________________________________________________________________
      47             : AliMUON1DMap::AliMUON1DMap(Int_t theSize)
      48           4 : : AliMUONVStore(),
      49          12 :   fMap(new AliMpExMap)
      50          20 : {
      51             : /// Default ctor
      52             : 
      53           4 :   if ( theSize > 0) 
      54             :   {
      55           4 :     fMap->SetSize(theSize);
      56             :   }
      57           4 :   fMap->SetOwner(kTRUE);
      58           8 : }
      59             : 
      60             : //_____________________________________________________________________________
      61             : AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
      62           0 : : AliMUONVStore(),
      63           0 :   fMap(new AliMpExMap(*other.fMap))
      64           0 : {
      65             : /// Copy constructor
      66           0 : }
      67             : 
      68             : //_____________________________________________________________________________
      69             : AliMUON1DMap&
      70             : AliMUON1DMap::operator=(const AliMUON1DMap& other)
      71             : {
      72             : /// Assignment operator
      73           0 :   *fMap = *other.fMap;
      74           0 :   return *this;
      75             : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMUON1DMap::~AliMUON1DMap()
      79          24 : {
      80             : /// destructor
      81           8 :   delete fMap;
      82          12 : }
      83             : 
      84             : //_____________________________________________________________________________
      85             : Bool_t 
      86             : AliMUON1DMap::Add(TObject* object)
      87             : {
      88             :   /// Add an object to this, using uniqueID as the key
      89        4176 :   if (!object) return kFALSE;
      90        2088 :   return Set(object->GetUniqueID(),object);
      91        2088 : }
      92             : 
      93             : //_____________________________________________________________________________
      94             : void 
      95             : AliMUON1DMap::Clear(Option_t*)
      96             : {
      97             :   /// Reset
      98           0 :   fMap->Clear();
      99           0 : }
     100             : 
     101             : //_____________________________________________________________________________
     102             : AliMUON1DMap* 
     103             : AliMUON1DMap::Create() const
     104             : {
     105             :   /// Create an empty clone of this
     106           0 :   return new AliMUON1DMap(fMap->GetSize());
     107           0 : }
     108             : 
     109             : //_____________________________________________________________________________
     110             : TObject* 
     111             : AliMUON1DMap::FindObject(UInt_t i) const
     112             : {
     113             : /// Get the object located at index i, if it exists, and if i is correct.
     114      273424 :   return fMap->GetValue(i);
     115             : }
     116             : 
     117             : //_____________________________________________________________________________
     118             : TObject* 
     119             : AliMUON1DMap::FindObject(Int_t i, Int_t j) const
     120             : {
     121             :   /// Get the object located at index (i,j), if it exists, and if i,j is correct.
     122             :   
     123           0 :   UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
     124             :   
     125           0 :   return fMap->GetValue(uid);
     126             : }
     127             : 
     128             : //_____________________________________________________________________________
     129             : TIterator*
     130             : AliMUON1DMap::CreateIterator() const
     131             : {
     132             :   /// Create and return an iterator on this map
     133             :   /// Returned iterator must be deleted by user.
     134           0 :   return fMap->CreateIterator();
     135             : }
     136             : 
     137             : //_____________________________________________________________________________
     138             : Int_t
     139             : AliMUON1DMap::GetSize() const
     140             : {
     141             :   /// Return the number of objects we hold
     142           0 :   return fMap->GetSize();
     143             : }
     144             : 
     145             : //_____________________________________________________________________________
     146             : Bool_t 
     147             : AliMUON1DMap::Set(Int_t i, TObject* object)
     148             : {
     149             : /// Set the object located at i
     150             : /// If there's already an object at location i,
     151             : /// this method fails and returns kFALSE, otherwise it returns kTRUE
     152             :   
     153        4176 :   TObject* o = FindObject(i);
     154        2088 :   if ( o )
     155             :   {
     156           0 :     AliError(Form("Object %p is already there for i=%d",o,i));
     157           0 :     return kFALSE;
     158             :   }
     159        2088 :   fMap->Add(i,object);
     160        2088 :   return kTRUE;
     161        2088 : }
     162             : 

Generated by: LCOV version 1.11