Added asserting copy constructors and assignment operators to volumes.

This commit is contained in:
unknown 2012-11-02 14:41:56 +01:00
parent 2566f3a7d2
commit b5414381ec
8 changed files with 150 additions and 31 deletions

View File

@ -141,13 +141,17 @@ namespace PolyVox
protected:
/// Constructor for creating a fixed size volume.
BaseVolume
(
const Region& regValid
);
BaseVolume(const Region& regValid);
/// Copy constructor
BaseVolume(const BaseVolume& rhs);
/// Destructor
~BaseVolume();
/// Assignment operator
BaseVolume& operator=(const BaseVolume& rhs);
//The size of the volume
Region m_regValidRegion;

View File

@ -23,15 +23,30 @@ freely, subject to the following restrictions:
namespace PolyVox
{
////////////////////////////////////////////////////////////////////////////////
/// This is protected because you should never create a BaseVolume directly, you should instead use one of the derived classes.
///
/// \sa RawVolume, SimpleVolume, LargeVolume
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
BaseVolume<VoxelType>::BaseVolume
(
const Region& regValid
)
BaseVolume<VoxelType>::BaseVolume(const Region& regValid)
:m_regValidRegion(regValid)
{
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
BaseVolume<VoxelType>::BaseVolume(const BaseVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// Destroys the volume
////////////////////////////////////////////////////////////////////////////////
@ -40,6 +55,19 @@ namespace PolyVox
{
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
BaseVolume<VoxelType>& BaseVolume<VoxelType>::operator=(const BaseVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// The border value is returned whenever an attempt is made to read a voxel which
/// is outside the extents of the volume.

View File

@ -297,7 +297,14 @@ namespace PolyVox
/// Calculates approximatly how many bytes of memory the volume is currently using.
uint32_t calculateSizeInBytes(void);
private:
protected:
/// Copy constructor
LargeVolume(const LargeVolume& rhs);
/// Assignment operator
LargeVolume& operator=(const LargeVolume& rhs);
private:
void initialise(const Region& regValidRegion, uint16_t uBlockSideLength);
/// gets called when a new region is allocated and needs to be filled

View File

@ -75,6 +75,19 @@ namespace PolyVox
initialise(regValid,uBlockSideLength);
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
LargeVolume<VoxelType>::LargeVolume(const LargeVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// Destroys the volume The destructor will call flushAll() to ensure that a paging volume has the chance to save it's data via the dataOverflowHandler() if desired.
////////////////////////////////////////////////////////////////////////////////
@ -85,6 +98,19 @@ namespace PolyVox
delete[] m_pUncompressedBorderData;
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
LargeVolume<VoxelType>& LargeVolume<VoxelType>::operator=(const LargeVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// The border value is returned whenever an atempt is made to read a voxel which
/// is outside the extents of the volume.

View File

@ -117,10 +117,8 @@ namespace PolyVox
public:
/// Constructor for creating a fixed size volume.
RawVolume
(
const Region& regValid
);
RawVolume(const Region& regValid);
/// Destructor
~RawVolume();
@ -141,7 +139,14 @@ namespace PolyVox
/// Calculates approximatly how many bytes of memory the volume is currently using.
uint32_t calculateSizeInBytes(void);
private:
protected:
/// Copy constructor
RawVolume(const RawVolume& rhs);
/// Assignment operator
RawVolume& operator=(const RawVolume& rhs);
private:
void initialise(const Region& regValidRegion);
//The block data

View File

@ -28,11 +28,8 @@ namespace PolyVox
/// \param regValid Specifies the minimum and maximum valid voxel positions.
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
RawVolume<VoxelType>::RawVolume
(
const Region& regValid
)
:BaseVolume<VoxelType>(regValid)
RawVolume<VoxelType>::RawVolume(const Region& regValid)
:BaseVolume<VoxelType>(regValid)
{
setBorderValue(VoxelType());
@ -40,6 +37,19 @@ namespace PolyVox
initialise(regValid);
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
RawVolume<VoxelType>::RawVolume(const RawVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// Destroys the volume
////////////////////////////////////////////////////////////////////////////////
@ -50,6 +60,19 @@ namespace PolyVox
m_pData = 0;
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
RawVolume<VoxelType>& RawVolume<VoxelType>::operator=(const RawVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// The border value is returned whenever an attempt is made to read a voxel which
/// is outside the extents of the volume.

View File

@ -152,11 +152,8 @@ namespace PolyVox
public:
/// Constructor for creating a fixed size volume.
SimpleVolume
(
const Region& regValid,
uint16_t uBlockSideLength = 32
);
SimpleVolume(const Region& regValid, uint16_t uBlockSideLength = 32);
/// Destructor
~SimpleVolume();
@ -177,7 +174,14 @@ namespace PolyVox
/// Calculates approximatly how many bytes of memory the volume is currently using.
uint32_t calculateSizeInBytes(void);
private:
protected:
/// Copy constructor
SimpleVolume(const SimpleVolume& rhs);
/// Assignment operator
SimpleVolume& operator=(const SimpleVolume& rhs);
private:
void initialise(const Region& regValidRegion, uint16_t uBlockSideLength);
Block* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;

View File

@ -29,17 +29,26 @@ namespace PolyVox
/// \param uBlockSideLength The size of the block to use within the volume
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
SimpleVolume<VoxelType>::SimpleVolume
(
const Region& regValid,
uint16_t uBlockSideLength
)
:BaseVolume<VoxelType>(regValid)
SimpleVolume<VoxelType>::SimpleVolume(const Region& regValid, uint16_t uBlockSideLength)
:BaseVolume<VoxelType>(regValid)
{
//Create a volume of the right size.
initialise(regValid,uBlockSideLength);
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
SimpleVolume<VoxelType>::SimpleVolume(const SimpleVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// Destroys the volume
////////////////////////////////////////////////////////////////////////////////
@ -50,6 +59,19 @@ namespace PolyVox
delete[] m_pUncompressedBorderData;
}
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
SimpleVolume<VoxelType>& SimpleVolume<VoxelType>::operator=(const SimpleVolume<VoxelType>& rhs)
{
assert(false); // See function comment above.
}
////////////////////////////////////////////////////////////////////////////////
/// The border value is returned whenever an attempt is made to read a voxel which
/// is outside the extents of the volume.