Sierra Toolkit Version of the Day
Property.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 
00010 #ifndef stk_mesh_Property_hpp
00011 #define stk_mesh_Property_hpp
00012 
00013 //----------------------------------------------------------------------
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include <stk_util/environment/ReportHandler.hpp>
00019 
00020 #include <stk_mesh/base/Types.hpp>
00021 #include <stk_mesh/base/MetaData.hpp>
00022 #include <stk_mesh/base/PropertyBase.hpp>
00023 
00024 //----------------------------------------------------------------------
00025 
00026 namespace stk {
00027 namespace mesh {
00028 
00034 std::ostream & operator << ( std::ostream & , const PropertyBase & );
00035 
00037 std::ostream & print( std::ostream & ,
00038                       const char * const , const PropertyBase & );
00039 
00041 template< typename property_type >
00042 inline
00043 const typename property_type::data_type *
00044 property_data( const property_type & prop , const Part & part )
00045 {
00046   const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop);
00047   const MetaData * prop_meta_data = & MetaData::get(prop_base);
00048   const MetaData * part_meta_data = & MetaData::get(part);
00049   ThrowRequireMsg( prop_meta_data == part_meta_data,
00050                    "MetaData mismatch between property and part" );
00051   return prop.data( part.mesh_meta_data_ordinal() );
00052 }
00053 
00055 template< typename property_type >
00056 inline
00057 typename property_type::data_type *
00058 property_data( property_type & prop , const Part & part )
00059 {
00060   const PropertyBase & prop_base = dynamic_cast< const PropertyBase & > (prop);
00061   const MetaData * prop_meta_data = & MetaData::get(prop_base);
00062   const MetaData * part_meta_data = & MetaData::get(part);
00063   ThrowRequireMsg( prop_meta_data == part_meta_data,
00064                    "MetaData mismatch between property and part" );
00065   return prop.data( part.mesh_meta_data_ordinal() );
00066 }
00067 
00070 } // namespace mesh
00071 } // namespace stk
00072 
00073 #endif /* stk_mesh_Property_hpp */
00074 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines