2014-02-10 19:53:03 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
|
|
|
// Copyright 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-02-10 19:53:03 +00:00
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
2014-03-07 15:19:09 +00:00
|
|
|
#ifndef vtk_m_cont_ArrayPortal_h
|
|
|
|
#define vtk_m_cont_ArrayPortal_h
|
2014-02-10 19:53:03 +00:00
|
|
|
|
|
|
|
#include <vtkm/Types.h>
|
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace cont {
|
|
|
|
|
|
|
|
#ifdef VTKM_DOXYGEN_ONLY
|
|
|
|
|
|
|
|
/// \brief A class that points to and access and array of data.
|
|
|
|
///
|
|
|
|
/// The ArrayPortal class itself does not exist; this code is provided for
|
|
|
|
/// documentation purposes only.
|
|
|
|
///
|
|
|
|
/// An ArrayPortal object acts like a pointer to a random-access container
|
|
|
|
/// (that is, an array) and also lets you set and get values in that array. In
|
|
|
|
/// many respects an ArrayPortal is similar in concept to that of iterators but
|
|
|
|
/// with a much simpler interface and no internal concept of position.
|
|
|
|
/// Otherwise, ArrayPortal objects may be passed and copied around so that
|
|
|
|
/// multiple entities may be accessing the same array.
|
|
|
|
///
|
|
|
|
/// An ArrayPortal differs from an ArrayHandle in that the ArrayPortal is a
|
|
|
|
/// much lighterweight object and that it does not manage things like
|
|
|
|
/// allocation and control/execution sharing. An ArrayPortal also differs from
|
2014-06-23 23:33:04 +00:00
|
|
|
/// a Storage in that it does not actually contain the data but rather
|
2014-02-10 19:53:03 +00:00
|
|
|
/// points to it. In this way the ArrayPortal can be copied and passed and
|
|
|
|
/// still point to the same data.
|
|
|
|
///
|
|
|
|
/// Most VTKm users generally do not need to do much or anything with
|
|
|
|
/// ArrayPortal objects. It is mostly an internal mechanism. However, an
|
|
|
|
/// ArrayPortal can be used to pass constant input data to an ArrayHandle.
|
|
|
|
///
|
2016-08-02 15:26:29 +00:00
|
|
|
/// Although portals are defined in the execution environment, they are also
|
|
|
|
/// used in the control environment for accessing data on the host.
|
2014-02-10 19:53:03 +00:00
|
|
|
///
|
|
|
|
template<typename T>
|
|
|
|
class ArrayPortal
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// The type of each value in the array.
|
|
|
|
///
|
|
|
|
typedef T ValueType;
|
|
|
|
|
|
|
|
/// The total number of values in the array. They are index from 0 to
|
|
|
|
/// GetNumberOfValues()-1.
|
|
|
|
///
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
vtkm::Id GetNumberOfValues() const;
|
|
|
|
|
|
|
|
/// Gets a value from the array.
|
|
|
|
///
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
ValueType Get(vtkm::Id index) const;
|
|
|
|
|
|
|
|
/// Sets a value in the array. This function may not exist for an ArrayPortal
|
|
|
|
/// pointing to a const array.
|
|
|
|
///
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Set(vtkm::Id index, const ValueType &value) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VTKM_DOXYGEN_ONLY
|
|
|
|
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
2014-06-11 16:43:36 +00:00
|
|
|
#endif //vtk_m_cont_ArrayPortal_h
|