H5DataTypes/src/AliasConfigV1.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: AliasConfigV1.cpp 6888 2013-10-02 19:07:59Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class AliasConfigV1...
00007 //
00008 // Author List:
00009 //      Andy Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "H5DataTypes/AliasConfigV1.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <algorithm>
00022 #include <cstring>
00023 
00024 //-------------------------------
00025 // Collaborating Class Headers --
00026 //-------------------------------
00027 #include "H5DataTypes/H5DataUtils.h"
00028 #include "hdf5pp/CompoundType.h"
00029 #include "hdf5pp/TypeTraits.h"
00030 
00031 //-----------------------------------------------------------------------
00032 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00033 //-----------------------------------------------------------------------
00034 
00035 //              ----------------------------------------
00036 //              -- Public Function Member Definitions --
00037 //              ----------------------------------------
00038 
00039 namespace H5DataTypes {
00040 
00041 
00042 hdf5pp::Type
00043 AliasPdsSrc::stored_type()
00044 {
00045   return native_type() ;
00046 }
00047 
00048 hdf5pp::Type
00049 AliasPdsSrc::native_type()
00050 {
00051   hdf5pp::CompoundType type = hdf5pp::CompoundType::compoundType<AliasPdsSrc>() ;
00052   type.insert_native<uint32_t>( "log", offsetof(AliasPdsSrc, log) ) ;
00053   type.insert_native<uint32_t>( "phy", offsetof(AliasPdsSrc, phy) ) ;
00054   return type;
00055 }
00056 
00057 
00058 AliasSrcAlias::AliasSrcAlias(const Pds::Alias::SrcAlias& srcAlias)
00059   : src(srcAlias.src())
00060 {
00061   std::fill_n(aliasName, int(AliasNameMax), '\0');
00062   std::strncpy(aliasName, srcAlias.aliasName(), AliasNameMax-1);
00063 }
00064 
00065 hdf5pp::Type
00066 AliasSrcAlias::stored_type()
00067 {
00068   return native_type() ;
00069 }
00070 
00071 hdf5pp::Type
00072 AliasSrcAlias::native_type()
00073 {
00074   hdf5pp::CompoundType type = hdf5pp::CompoundType::compoundType<AliasSrcAlias>() ;
00075   type.insert( "src", offsetof(AliasSrcAlias, src), AliasPdsSrc::native_type() ) ;
00076   type.insert_native<const char*>( "aliasName", offsetof(AliasSrcAlias, aliasName), AliasNameMax ) ;
00077   return type;
00078 }
00079 
00080 
00081 AliasConfigV1::AliasConfigV1(const XtcType& data)
00082   : numSrcAlias(data.numSrcAlias())
00083 {
00084 }
00085 
00086 hdf5pp::Type
00087 AliasConfigV1::stored_type()
00088 {
00089   return native_type() ;
00090 }
00091 
00092 hdf5pp::Type
00093 AliasConfigV1::native_type()
00094 {
00095   hdf5pp::CompoundType type = hdf5pp::CompoundType::compoundType<AliasConfigV1>() ;
00096   type.insert_native<uint32_t>( "numSrcAlias", offsetof(AliasConfigV1, numSrcAlias) ) ;
00097   return type;
00098 }
00099 
00100 void
00101 AliasConfigV1::store(const XtcType& config, hdf5pp::Group grp)
00102 {
00103   // make scalar data set for main object
00104   AliasConfigV1 data(config);
00105   storeDataObject ( data, "config", grp ) ;
00106 
00107   // make array data set for subobject
00108   const ndarray<const Pds::Alias::SrcAlias, 1>& pdsdata = config.srcAlias();
00109   const uint32_t count = pdsdata.size();
00110   AliasSrcAlias adata[count];
00111   for ( uint32_t i = 0 ; i < count ; ++ i ) {
00112     adata[i] = AliasSrcAlias(pdsdata[i]);
00113   }
00114   storeDataObjects ( count, adata, "aliases", grp ) ;
00115 }
00116 
00117 } // namespace H5DataTypes

Generated on 19 Dec 2016 for PSDMSoftware by  doxygen 1.4.7