Sleipnir
src/examplei.h
00001 /*****************************************************************************
00002 * This file is provided under the Creative Commons Attribution 3.0 license.
00003 *
00004 * You are free to share, copy, distribute, transmit, or adapt this work
00005 * PROVIDED THAT you attribute the work to the authors listed below.
00006 * For more information, please see the following web page:
00007 * http://creativecommons.org/licenses/by/3.0/
00008 *
00009 * This file is a component of the Sleipnir library for functional genomics,
00010 * authored by:
00011 * Curtis Huttenhower (chuttenh@princeton.edu)
00012 * Mark Schroeder
00013 * Maria D. Chikina
00014 * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
00015 *
00016 * If you use this library, the included executable tools, or any related
00017 * code in your work, please cite the following publication:
00018 * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
00019 * Olga G. Troyanskaya.
00020 * "The Sleipnir library for computational functional genomics"
00021 *****************************************************************************/
00022 #ifndef EXAMPLEI_H
00023 #define EXAMPLEI_H
00024 
00025 #include <utility>
00026 
00027 #include "datapair.h"
00028 
00029 namespace Sleipnir {
00030 
00031 class CExampleImpl {
00032 public:
00033     CExampleImpl( );
00034     ~CExampleImpl( );
00035 
00036     void Set( size_t, float, const CDataPair&, size_t );
00037     bool Equals( const CExampleImpl&, size_t ) const;
00038     void Reset( );
00039     bool IsEvidence( size_t ) const;
00040 
00041     size_t GetDiscrete( size_t iDatum ) const {
00042 
00043         return m_auData[ iDatum ].m_i; }
00044 
00045     float GetContinuous( size_t iDatum ) const {
00046 
00047         return m_auData[ iDatum ].m_d; }
00048 
00049     bool IsSet( ) const {
00050 
00051         return !!m_auData; }
00052 
00053 protected:
00054     union UDatum {
00055         float   m_d;
00056         size_t  m_i;
00057     };
00058 
00059     UDatum* m_auData;
00060 };
00061 
00062 }
00063 
00064 #endif // EXAMPLEI_H