Documentation for ArraySizes.

This commit is contained in:
David Williams 2010-03-27 23:45:41 +00:00
parent 2db384b1bc
commit 8240d477bd
5 changed files with 89 additions and 95 deletions

View File

@ -21,8 +21,8 @@ SET(CORE_SRC_FILES
SET(CORE_INC_FILES
include/Array.h
include/Array.inl
include/Dimensions.h
include/Dimensions.inl
include/ArraySizes.h
include/ArraySizes.inl
include/GradientEstimators.inl
include/SurfaceMesh.h
include/Log.h
@ -49,6 +49,8 @@ SET(IMPL_SRC_FILES
)
SET(IMPL_INC_FILES
include/PolyVoxImpl/ArraySizesImpl.h
include/PolyVoxImpl/ArraySizesImpl.inl
include/PolyVoxImpl/Block.h
include/PolyVoxImpl/Block.inl
include/PolyVoxImpl/CPlusPlusZeroXSupport.h

View File

@ -27,6 +27,8 @@ freely, subject to the following restrictions:
#define __PolyVox_Array_H__
#pragma region Headers
#include "ArraySizes.h" //Not strictly required, but convienient
#include "PolyVoxImpl/TypeDef.h"
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
#pragma endregion

View File

@ -0,0 +1,83 @@
#pragma region License
/*******************************************************************************
Copyright (c) 2005-2009 David Williams
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*******************************************************************************/
#pragma endregion
#ifndef __PolyVox_ArraySizes_H__
#define __PolyVox_ArraySizes_H__
#pragma region Headers
#include "PolyVoxImpl/ArraySizesImpl.h"
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
#pragma endregion
namespace PolyVox
{
///The ArraySizes class provide a convienient way to specify the dimensions of an Array.
////////////////////////////////////////////////////////////////////////////////
/// The Array class requires an array of integers to be passed to the constructor
/// to specify the dimensions of the Array to be built. C++ does not allow this to
/// be done in place, and so it typically requires an extra line of code - something
/// like this:
///
/// \code
/// uint32_t dimensions[3] = {10, 20, 30}; // Array dimensions
/// Array<3,float> array(dimensions);
/// \endcode
///
/// The ArraySizes class can be constructed in place, and also provides implicit
/// conversion to an array of integers. Hence it is now possible to declare the
/// above Array as follows:
///
/// \code
/// Array<3,float> array(ArraySizes(10)(20)(30));
/// \endcode
///
/// Usage of this class is therefore very simple, although the template code
/// behind it may appear complex. For reference, it is based upon the article here:
/// http://www.drdobbs.com/cpp/184401319/
////////////////////////////////////////////////////////////////////////////////
class ArraySizes
{
typedef const uint32_t (&UIntArray1)[1];
public:
/// Constructor
explicit ArraySizes(uint32_t uSize);
/// Duplicates this object but with an extra dimension
ArraySizesImpl<2> operator () (uint32_t uSize);
/// Converts this object to an array of integers
operator UIntArray1 () const;
private:
// This class is only one dimensional. Higher dimensions
// are implemented via the ArraySizesImpl class.
uint32_t m_pSizes[1];
};
}//namespace PolyVox
#include "ArraySizes.inl"
#endif //__PolyVox_ArraySizes_H__

View File

@ -1,92 +0,0 @@
#pragma region License
/*******************************************************************************
Copyright (c) 2005-2009 David Williams
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*******************************************************************************/
#pragma endregion
#ifndef __PolyVox_Dimensions_H__
#define __PolyVox_Dimensions_H__
#pragma region Headers
#include "PolyVoxImpl/TypeDef.h"
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
#pragma endregion
namespace PolyVox
{
template <uint32_t N>
class ArraySizesImpl
{
typedef const uint32_t (&UIntArrayN)[N];
friend class ArraySizes;
friend class ArraySizesImpl<N-1>;
public:
ArraySizesImpl<N+1> operator () (uint32_t uSize)
{
return ArraySizesImpl<N+1>(m_pSizes, uSize);
}
operator UIntArrayN () const
{
return m_pSizes;
}
private:
ArraySizesImpl(const uint32_t (&pSizes)[N-1], uint32_t uSize)
{
std::copy(&pSizes[0],&pSizes[N-1],m_pSizes);
m_pSizes[N-1]=uSize;
}
uint32_t m_pSizes[N];
};
class ArraySizes
{
typedef const uint32_t (&UIntArray1)[1];
public:
explicit ArraySizes(uint32_t uSize)
{
m_pSizes[0]=uSize;
}
ArraySizesImpl<2> operator () (uint32_t uSize)
{
return ArraySizesImpl<2>(m_pSizes, uSize);
}
operator UIntArray1 () const
{
return m_pSizes;
}
private:
uint32_t m_pSizes[1];
};
}//namespace PolyVox
#include "Array.inl"
#endif //__PolyVox_Dimensions_H__

View File

@ -24,7 +24,6 @@ freely, subject to the following restrictions:
#include "SurfaceExtractor.h"
#include "Array.h"
#include "Dimensions.h"
#include "SurfaceMesh.h"
#include "PolyVoxImpl/MarchingCubesTables.h"
#include "SurfaceVertex.h"