Commit 295518ab authored by Stéphane Albert's avatar Stéphane Albert
Browse files

ENH: Moved otb::DynamicCast<> and otb::ConstCast<> into Core/Common module.

parent df049a1f
/*=========================================================================
* TODO: Add licence notice.
*=======================================================================*/
// Submitted by Stéphane ALBERT (otb.salbert@gmail.com).
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.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 notices for more information.
*=======================================================================*/
#ifndef __itkCasts_h
#define __itkCasts_h
#ifndef __otbCast_h
#define __otbCast_h
#include "itkSmartPointer.h"
namespace itk
namespace otb
{
/**
* \brief dynamic_cast<>() like operator to work with itk::SmartPointer<>.
......@@ -79,6 +91,6 @@ ConstCast( const itk::SmartPointer< const T1 > & p1 )
);
}
} // end namespace itk.
} // end namespace otb.
#endif // __itkCasts_h
#endif // __otbCast_h
......@@ -51,73 +51,16 @@
//
// OTB includes (sorted by alphabetic order)
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 //tag=QT4-boost-compatibility
#ifndef Q_MOC_RUN // See:
// https://bugreports.qt-project.org/browse/QTBUG-22829
// //tag=QT4-boost-compatibility
#include <otbCast.h>
#include <otbImage.h>
#include <otbImageFileReader.h>
#include <otbImageFileWriter.h>
#include <otbVectorImage.h>
#endif //tag=QT4-boost-compatibility
////
//// O T B
////
// TODO: Contribute to OTB!
namespace otb
{
/**
*/
template< typename T2, typename T1 >
inline
itk::SmartPointer< T2 >
DynamicCast( const itk::SmartPointer< T1 >& p1 )
{
return
typename itk::SmartPointer< T2 >(
dynamic_cast< typename itk::SmartPointer< T2 >::ObjectType* >(
p1.GetPointer()
)
);
}
/**
*/
template< typename T2, typename T1 >
inline
itk::SmartPointer< const T2 >
ConstCast( const itk::SmartPointer< T1 >& p1 )
{
return
typename itk::SmartPointer< const T2 >(
const_cast< typename itk::SmartPointer< const T2 >::ObjectType* >(
p1.GetPointer()
)
);
}
/**
*/
template< typename T2, typename T1 >
inline
itk::SmartPointer< T2 >
ConstCast( const itk::SmartPointer< const T1 >& p1 )
{
return
typename itk::SmartPointer< T2 >(
const_cast< typename itk::SmartPointer< T2 >::ObjectType* >(
p1.GetPointer()
)
);
}
} // end of namespace otb.
////
//// M V D 2
////
//
// Monteverdi includes (sorted by alphabetic order)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment