MAK RTIspy API Documentation for HLA 1516
statisticsXmlBlock.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  ** Copyright (c) 2006 MaK Technologies, Inc.
00003  ** All rights reserved.
00004  *********************************************************************/
00005 /*******************************************************************************
00006  ** $RCSfile: statisticsXmlBlock.h,v $ $Revision: 1.12 $ $State: Exp $
00007  *******************************************************************************/
00008 #ifndef DtStatisticsXmlBlock_H_
00009 #define DtStatisticsXmlBlock_H_
00010 
00011 // file statisticsXmlBlock.h
00012 
00013 #include "spyXmlBlock.h"
00014 #include <mtl/env.h>
00015 #include "pluggableFactory.h"
00016 
00017 #include <vlutil/vlString.h>
00018 #include <vlutil/vlSmartPointers.h>
00019 
00020 // Define the XML tags used by this block
00021 DtDECLARE_SPY_XML_TAG( DtStatisticsXmlTag );
00022 DtDECLARE_SPY_XML_TAG( DtUintStatisticsXmlTag );
00023 DtDECLARE_SPY_XML_TAG( DtIntStatisticsXmlTag );
00024 DtDECLARE_SPY_XML_TAG( DtFloatStatisticsXmlTag );
00025 DtDECLARE_SPY_XML_TAG( DtDoubleStatisticsXmlTag );
00026 DtDECLARE_SPY_XML_TAG( DtStatisticsTotalXmlTag );
00027 DtDECLARE_SPY_XML_TAG( DtStatisticsCountXmlTag );
00028 DtDECLARE_SPY_XML_TAG( DtStatisticsMinXmlTag );
00029 DtDECLARE_SPY_XML_TAG( DtStatisticsMaxXmlTag );
00030 DtDECLARE_SPY_XML_TAG( DtStatisticsAvgXmlTag );
00031 
00036 template < typename NumericType >
00037 class DtStatisticsXmlBlock : public DtSpyXmlBlock
00038 {
00039 public:
00040    typedef NumericType ValueType;
00041    typedef DtBoost::shared_ptr< DtStatisticsXmlBlock< NumericType > > BlockSP;
00042    typedef DtBoost::weak_ptr< DtStatisticsXmlBlock< NumericType > >   BlockWP;
00043    
00044    // Creator method
00045    static DtSpyXmlBlockSP create( DtNodeAndParentPair xmlNodeAndParent );
00046 
00047 public:
00048    // Ctor to build from XML data
00049    DtStatisticsXmlBlock( MAKRti::DtEnvValueSP existingNode, MAKRti::DtEnvValueSP root );
00050 
00051    // Ctor to build from C++ data
00052    DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );   
00053    virtual ~DtStatisticsXmlBlock();
00054 
00055    // Reset the data
00056    virtual void reset();
00057 
00058    // Force the value
00059    virtual void set( unsigned int count, ValueType total, ValueType minimum,
00060       ValueType maximum, ValueType average );
00061 
00062 
00063    // Add an element and update stats
00064    virtual void addStatistic( const NumericType& stat );
00065 
00066    // Accessors
00067    unsigned int count() const;
00068    ValueType total() const;
00069    ValueType minimum() const;
00070    ValueType maximum() const;   
00071    double average() const;
00072 
00073 protected:
00074 
00075    // Protected Ctor to build from C++ data
00076    // For use only by derived classes that want to change the type tag of the XML block.
00077    DtStatisticsXmlBlock( const MAKRti::DtString& name, const MAKRti::DtString& typeTag, MAKRti::DtEnvValueSP root );   
00078    
00079 protected:
00080 
00081    bool myInReset;
00082 
00083    DtSpyXmlBlockElement< unsigned int, true > myCount;
00084    DtSpyXmlBlockElement< NumericType, true > myTotal;
00085    DtSpyXmlBlockElement< NumericType, true > myMin;
00086    DtSpyXmlBlockElement< NumericType, true > myMax;
00087    DtSpyXmlBlockElement< double, true > myAvg;
00088 
00089 };
00090 
00091 
00092 // Specializations for types registered with pluggable factory
00093 
00094 //versions of gcc prior to 3.4 do not accept the correct template specialization syntax
00095 #if (( __GNUC__ == 3 ) && ( __GNUC_MINOR__ < 4 ))
00096 
00097 DtStatisticsXmlBlock< unsigned int >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00098 
00099 DtStatisticsXmlBlock< int >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00100 
00101 DtStatisticsXmlBlock< float >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00102 
00103 DtStatisticsXmlBlock< double >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00104 
00105 #else
00106 
00107 template <>
00108 DtStatisticsXmlBlock< unsigned int >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00109 
00110 template <>
00111 DtStatisticsXmlBlock< int >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00112 
00113 template <>
00114 DtStatisticsXmlBlock< float >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00115 
00116 template <>
00117 DtStatisticsXmlBlock< double >::DtStatisticsXmlBlock( const MAKRti::DtString& name, MAKRti::DtEnvValueSP root );
00118 
00119 #endif  // __GNUC__ specific
00120 
00121 
00122 
00123 #define statisticsXmlBlock_inl_
00124 #include "statisticsXmlBlock.inl"
00125 #undef  statisticsXmlBlock_inl_
00126 
00127 #endif // DtStatisticsXmlBlock_H_
00128 

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)