FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
down_cast.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include <Handle_Standard_Transient.hxx>
19 
20 namespace occ {
21 
38 template<typename TYPE>
39 class down_cast
40 {
41 public:
42  explicit down_cast<TYPE>(const Handle_Standard_Transient& handle);
43  operator TYPE() const;
44  const TYPE operator->() const;
45 private:
46  const Handle_Standard_Transient& m_handle;
47 };
48 
49 
50 
51 // --
52 // -- Implementation
53 // --
54 
56 template<typename TYPE>
57 down_cast<TYPE>::down_cast(const Handle_Standard_Transient& handle)
58  : m_handle(handle)
59 {
60 }
61 
63 template<typename TYPE>
64 down_cast<TYPE>::operator TYPE() const
65 {
66  return TYPE::DownCast(m_handle);
67 }
68 
70 template<typename TYPE>
71 const TYPE down_cast<TYPE>::operator->() const
72 {
73  return TYPE::DownCast(m_handle);
74 }
75 } // namespace occ
const TYPE operator->() const
Downcasted handle to type TYPE.
Definition: down_cast.h:71
Definition: ais_text.cpp:31
down_cast(const Handle_Standard_Transient &handle)
Construct the operator that will down cast object to an handle of type TYPE.
Definition: down_cast.h:57
Downcasting operator for OpenCascade handles.
Definition: down_cast.h:39