greenplumn CAutoRg 源码
greenplumn CAutoRg 代码
文件路径:/src/backend/gporca/libgpos/include/gpos/common/CAutoRg.h
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2008 Greenplum, Inc.
//
// @filename:
// CAutoRg.h
//
// @doc:
// Basic auto range implementation; do not anticipate ownership based
// on assignment to other auto ranges etc. Require explicit return/assignment
// to re-init the object;
//---------------------------------------------------------------------------
#ifndef GPOS_CAutoRg_H
#define GPOS_CAutoRg_H
#include "gpos/base.h"
#include "gpos/common/CStackObject.h"
namespace gpos
{
//---------------------------------------------------------------------------
// @class:
// CAutoRg
//
// @doc:
// Wrapper around arrays analogous to CAutoP
//
//---------------------------------------------------------------------------
template <class T>
class CAutoRg : public CStackObject
{
private:
// actual element to point to
T *m_object_array;
public:
CAutoRg<T>(const CAutoRg &) = delete;
// ctor
explicit CAutoRg<T>() : m_object_array(nullptr)
{
}
// ctor
explicit CAutoRg<T>(T *object_array) : m_object_array(object_array)
{
}
// dtor
virtual ~CAutoRg();
// simple assignment
inline CAutoRg<T> const &
operator=(T *object_array)
{
m_object_array = object_array;
return *this;
}
// indexed access
inline T &
operator[](ULONG ulPos)
{
return m_object_array[ulPos];
}
// return basic pointer
T *
Rgt()
{
return m_object_array;
}
// unhook pointer from auto object
inline T *
RgtReset()
{
T *object_array = m_object_array;
m_object_array = nullptr;
return object_array;
}
}; // class CAutoRg
//---------------------------------------------------------------------------
// @function:
// CAutoRg::~CAutoRg
//
// @doc:
// Dtor
//
//---------------------------------------------------------------------------
template <class T>
CAutoRg<T>::~CAutoRg()
{
GPOS_DELETE_ARRAY(m_object_array);
}
} // namespace gpos
#endif // !GPOS_CAutoRg_H
// EOF
相关信息
相关文章
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦