• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/hpp/dds/core/detail/ref_traits.hpp

Go to the documentation of this file.
00001 #ifndef OMG_DDS_CORE_DETAIL_REF_TRAITS_H_
00002 #define OMG_DDS_CORE_DETAIL_REF_TRAITS_H_
00003 
00004 /* Copyright 2010, Object Management Group, Inc.
00005  * Copyright 2010, PrismTech, Corp.
00006  * Copyright 2010, Real-Time Innovations, Inc.
00007  * All rights reserved.
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License");
00010  * you may not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  *     http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS,
00017  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include <boost/shared_ptr.hpp>
00023 #include <boost/weak_ptr.hpp>
00024 #include <boost/static_assert.hpp>
00025 #include <boost/type_traits.hpp>
00026 
00027 #include <dds/core/corefwd.hpp>
00028 #include <dds/core/types.hpp>
00029 #include <dds/core/Exception.hpp>
00030 
00031 template <typename T1, typename T2>
00032 struct dds::core::is_base_of : public boost::is_base_of<T1, T2> { };
00033 
00034 template <typename T1, typename T2>
00035 struct dds::core::is_same : public boost::is_same<T1, T1> { };
00036 
00037 template <typename T>
00038 struct dds::core::smart_ptr_traits {
00039     typedef boost::shared_ptr<T> ref_type;
00040     typedef boost::weak_ptr<T>   weak_ref_type;
00041 };
00042 
00043 
00044 template <typename TO, typename FROM>
00045 TO dds::core::polymorphic_cast(FROM& from) {
00046     typename TO::DELEGATE_REF_T dr =
00047             boost::dynamic_pointer_cast< typename TO::DELEGATE_T>(from.delegate());
00048     TO to(dr);
00049 
00050     if (to == dds::core::null)
00051         throw dds::core::InvalidDowncastError("Attempted invalid downcast.");
00052     return to;
00053 }
00054 #endif /* OMG_DDS_CORE_DETAIL_REF_TRAITS_H_ */
00055 

Generated on Tue Nov 9 2010 02:16:21 for dds-psm-cxx-doc by  doxygen 1.7.1