]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Getting rid of effC++ warnings about missing copy constructor and assignment operator.
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 10:29:46 +0000 (10:29 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 10:29:46 +0000 (10:29 +0000)
HLT/MUON/AliHLTMUONDataBlockReader.h
HLT/MUON/AliHLTMUONDataBlockWriter.h

index 5b69058aa854d00e6ac81166f79d198d1d65af5e..ce604c61c0c1a3137b3d18b7a0e731d845a846de 100644 (file)
@@ -90,6 +90,31 @@ public:
        {
                assert( buffer != NULL );
        }
+       
+       /**
+        * Copy constructor that performs a shallow copy.
+        * Since this class does not take direct ownership of the buffer, never
+        * allocates or deallocates memory, this can be allowed.
+        */
+       AliHLTMUONDataBlockReader(const AliHLTMUONDataBlockReader& reader)
+       {
+               fSize = reader.fSize;
+               fBlock = reader.fBlock;
+               fData = reader.fData;
+       }
+       
+       /**
+        * Assignment operator performs a shallow copy.
+        * This is OK because this class does not take direct ownership of the
+        * output memory buffer.
+        */
+       AliHLTMUONDataBlockReader& operator = (const AliHLTMUONDataBlockReader& reader)
+       {
+               fSize = reader.fSize;
+               fBlock = reader.fBlock;
+               fData = reader.fData;
+               return *this;
+       }
 
        /**
         * Checks that the size of the buffer storing the data block is correct.
index 73c7e1c9e6f5bf8600f07c46cfeb540c3e9b6af7..1d4c6abfd58475f6518ccd2ccd0431958c2f9ffc 100644 (file)
@@ -113,7 +113,7 @@ public:
         */
        AliHLTMUONDataBlockWriter(void* buffer, AliHLTUInt32_t size) :
                fSize(size),
-               fMaxArraySize(size - sizeof(DataBlockType)),
+               fMaxArraySize(size > sizeof(DataBlockType) ? size - sizeof(DataBlockType) : 0),
                fBlock(reinterpret_cast<DataBlockType*>(buffer)),
                fData(reinterpret_cast<DataElementType*>(
                       reinterpret_cast<DataBlockType*>(buffer) + 1
@@ -121,6 +121,33 @@ public:
        {
                assert( buffer != NULL );
        }
+       
+       /**
+        * Copy constructor that performs a shallow copy.
+        * Since this class does not take direct ownership of the buffer, never
+        * allocates or deallocates memory, this can be allowed.
+        */
+       AliHLTMUONDataBlockWriter(const AliHLTMUONDataBlockWriter& writer)
+       {
+               fSize = writer.fSize;
+               fMaxArraySize = writer.fMaxArraySize;
+               fBlock = writer.fBlock;
+               fData = writer.fData;
+       }
+       
+       /**
+        * Assignment operator performs a shallow copy.
+        * This is OK because this class does not take direct ownership of the
+        * output memory buffer.
+        */
+       AliHLTMUONDataBlockWriter& operator = (const AliHLTMUONDataBlockWriter& writer)
+       {
+               fSize = writer.fSize;
+               fMaxArraySize = writer.fMaxArraySize;
+               fBlock = writer.fBlock;
+               fData = writer.fData;
+               return *this;
+       }
 
        /**
         * Initialises the common data block header by setting the type and record