/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
DayaBay::UserDataHeader Class Reference

General container for user-defined data. More...

#include <UserDataHeader.h>

Inheritance diagram for DayaBay::UserDataHeader:
Inheritance graph
[legend]
Collaboration diagram for DayaBay::UserDataHeader:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector
< DayaBay::UserData * > 
UserDataList
 Container for user-defined data.
typedef std::vector< IHeader * > Vector
typedef std::vector< const
IHeader * > 
ConstVector

Public Member Functions

virtual const std::string & defLoc () const
 UserDataHeader ()
 Default Constructor.
virtual ~UserDataHeader ()
 destructor
virtual const CLID & clID () const
void clearData ()
 Clear user data.
void setInt (const std::string &name, const int &value)
 Set a user-defined data name and value.
void setIntArray (const std::string &name, const std::vector< int > &value)
 Set a user-defined data name and value.
void setFloat (const std::string &name, const float &value)
 Set a user-defined data name and value.
void setFloatArray (const std::string &name, const std::vector< float > &value)
 Set a user-defined data name and value.
int getInt (const std::string &name, int def=0)
 Get a user-defined data as an int.
std::vector< int > getIntArray (const std::string &name)
 Get a user-defined data as an vector<int>
float getFloat (const std::string &name, float def=0.0)
 Get a user-defined data as a float.
std::vector< float > getFloatArray (const std::string &name)
 Get a user-defined data as a vector<float>
void set (const std::string &name, const int &value)
 Set a user-defined data name and value.
void set (const std::string &name, const float &value)
 Set a user-defined data name and value.
void set (const std::string &name, const std::vector< int > &value)
 Set a user-defined data name and value.
void set (const std::string &name, const std::vector< float > &value)
 Set a user-defined data name and value.
UserDataget (const std::string &name)
 Get a user-defined data name and value.
std::ostream & fillStream (std::ostream &s) const
 Serialize to an ostream.
const UserDataListdata () const
 Retrieve const List of user-defined data.
UserDataListdata ()
 Retrieve List of user-defined data.
void setData (const UserDataList &value)
 Update List of user-defined data.
virtual const std::string & defLoc ()
void setInputHeaders (const std::vector< const DayaBay::IHeader * > &iheaders)
void clearInputHeaders ()
void addInputHeader (const DayaBay::IHeader *iheader)
const TimeStamptimeStamp () const
void setTimeStamp (const TimeStamp &ts)
const std::vector< const
DayaBay::IHeader * > 
findHeaders (const CLID &clid) const
const std::vector< const
DayaBay::IHeader * > 
findHeaders (const std::string &name) const
const Contextcontext () const
void setContext (const Context &value)
int execNumber () const
void setExecNumber (int value)
const std::vector< unsigned
long > & 
randomState () const
void setRandomState (const std::vector< unsigned long > &value)
const std::vector< const
DayaBay::IHeader * > & 
inputHeaders () const
const DayaBay::JobIdjobId () const
void setJobId (const DayaBay::JobId &value)
virtual void setOutputAddress (const GenericAddress *roa)
virtual void setInputAddress (const GenericAddress *ria)
virtual const TimeStampearliest () const
void setEarliest (const TimeStamp &value)
virtual const TimeStamplatest () const
void setLatest (const TimeStamp &value)
virtual const GenericAddress * outputAddress () const
virtual const GenericAddress * inputAddress () const

Static Public Member Functions

static const std::string & defaultLocation ()
 Give access to default location from class scope.
static const CLID & classID ()
static UserDataHeadercreate ()
 Make a new UserDataHeader.
static void * operator new (size_t size)
 operator new
static void * operator new (size_t size, void *pObj)
 placement operator new it is needed by libstdc++ 3.2.3 (e.g.
static void operator delete (void *p)
 operator delete
static void operator delete (void *p, void *pObj)
 placement operator delete not sure if really needed, but it does not harm

Private Attributes

UserDataList m_data
 List of user-defined data.

Detailed Description

General container for user-defined data.

Author:
dandwyer@caltech.edu created Thu Dec 5 17:41:14 2013

Definition at line 55 of file UserDataHeader.h.


Member Typedef Documentation

Container for user-defined data.

Definition at line 64 of file UserDataHeader.h.


Constructor & Destructor Documentation

DayaBay::UserDataHeader::UserDataHeader ( ) [inline]

Default Constructor.

Definition at line 67 of file UserDataHeader.h.

: m_data() {}
DayaBay::UserDataHeader::~UserDataHeader ( ) [virtual]

destructor

Definition at line 11 of file UserDataHeader.cc.

{
    // cerr << "Destroying UserDataHeader (" << (void*)this << ") "
    //      << "#" << this->execNumber() << " @" << this->timeStamp().AsString() 
    //      << endl;

  // Destructor
  this->clearData();
}

Member Function Documentation

static const std::string& DayaBay::UserDataHeader::defaultLocation ( ) [inline, static]

Give access to default location from class scope.

Reimplemented from DayaBay::HeaderObject.

Definition at line 60 of file UserDataHeader.h.

virtual const std::string& DayaBay::UserDataHeader::defLoc ( ) const [inline, virtual]

Reimplemented from DayaBay::HeaderObject.

Definition at line 61 of file UserDataHeader.h.

const CLID & DayaBay::UserDataHeader::clID ( ) const [inline, virtual]

Reimplemented from DayaBay::HeaderObject.

Definition at line 200 of file UserDataHeader.h.

const CLID & DayaBay::UserDataHeader::classID ( ) [inline, static]

Reimplemented from DayaBay::HeaderObject.

Definition at line 205 of file UserDataHeader.h.

{
  return CLID_UserDataHeader;
}
DayaBay::UserDataHeader * DayaBay::UserDataHeader::create ( ) [static]

Make a new UserDataHeader.

Definition at line 6 of file UserDataHeader.cc.

{
    return new UserDataHeader;
}
void DayaBay::UserDataHeader::clearData ( )

Clear user data.

Definition at line 21 of file UserDataHeader.cc.

{
  for (size_t ind=0; ind<m_data.size(); ++ind) {
    delete m_data[ind];
    m_data[ind]=0;
  }
  m_data.clear();
}
void DayaBay::UserDataHeader::setInt ( const std::string &  name,
const int &  value 
)

Set a user-defined data name and value.

Definition at line 46 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);
    if( !data ) { 
        // If data field doesn't exist, create it
        m_data.push_back( new DayaBay::UserInt(name, value) );
        return;
    }
    if(data->type() != DayaBay::UserData::Int){
        // Error! Wrong data type   // <-- passive-aggressive comment
        return;
    }
    // If data field exists, reset value
    (dynamic_cast<DayaBay::UserInt*>(data))->setValue( value );
}
void DayaBay::UserDataHeader::setIntArray ( const std::string &  name,
const std::vector< int > &  value 
)

Set a user-defined data name and value.

Definition at line 63 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);
    if(!data ){ 
        // If data field doesn't exist, create it
        m_data.push_back( new DayaBay::UserIntArray(name, value) );
        return;
    }
    if(data->type() != DayaBay::UserData::IntArray){
        // Error! Wrong data type
        return;
    }
    // If data field exists, reset value
    (dynamic_cast<UserIntArray*>(data))->setValue( value );
}
void DayaBay::UserDataHeader::setFloat ( const std::string &  name,
const float &  value 
)

Set a user-defined data name and value.

Definition at line 81 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);
    if( !data ){ 
        // If data field doesn't exist, create it
        m_data.push_back( new DayaBay::UserFloat(name, value) );
        return;
    }
    if(data->type() != DayaBay::UserData::Float){
        // Error! Wrong data type
        return;
    }
    // If data field exists, reset value
    (dynamic_cast<DayaBay::UserFloat*>(data))->setValue( value );
}
void DayaBay::UserDataHeader::setFloatArray ( const std::string &  name,
const std::vector< float > &  value 
)

Set a user-defined data name and value.

Definition at line 98 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);
    if(!data ){ 
        // If data field doesn't exist, create it
        m_data.push_back( new DayaBay::UserFloatArray(name, value) );
        return;
    }
    if(data->type() != DayaBay::UserData::FloatArray){
        // Error! Wrong data type
        return;
    }
    // If data field exists, reset value
    (dynamic_cast<UserFloatArray*>(data))->setValue( value );
}
int DayaBay::UserDataHeader::getInt ( const std::string &  name,
int  def = 0 
)

Get a user-defined data as an int.

Definition at line 115 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);

    if (!data) { return def; }
    if (data->type() != DayaBay::UserData::Int) { return def; }

    return (dynamic_cast<DayaBay::UserInt*>(data))->value();
}
std::vector< int > DayaBay::UserDataHeader::getIntArray ( const std::string &  name)

Get a user-defined data as an vector<int>

Definition at line 125 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);

    if (!data) { return std::vector<int>(); }
    if (data->type() != DayaBay::UserData::IntArray) { 
        return std::vector<int>(); 
    }

    return (dynamic_cast<DayaBay::UserIntArray*>(data))->value();
}
float DayaBay::UserDataHeader::getFloat ( const std::string &  name,
float  def = 0.0 
)

Get a user-defined data as a float.

Definition at line 137 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);

    if (!data) { return def; }
    if (data->type() != DayaBay::UserData::Float) { return def; }

    return (dynamic_cast<DayaBay::UserFloat*>(data))->value();
}
std::vector< float > DayaBay::UserDataHeader::getFloatArray ( const std::string &  name)

Get a user-defined data as a vector<float>

Definition at line 147 of file UserDataHeader.cc.

{
    DayaBay::UserData* data = this->get(name);

    if (!data) { return std::vector<float>(); }
    if (data->type() != DayaBay::UserData::FloatArray) { 
        return std::vector<float>(); 
    }

    return (dynamic_cast<DayaBay::UserFloatArray*>(data))->value();
}
void DayaBay::UserDataHeader::set ( const std::string &  name,
const int &  value 
) [inline]

Set a user-defined data name and value.

Definition at line 225 of file UserDataHeader.h.

{
this->setInt(name,value);
}
void DayaBay::UserDataHeader::set ( const std::string &  name,
const float &  value 
) [inline]

Set a user-defined data name and value.

Definition at line 231 of file UserDataHeader.h.

{
this->setFloat(name, value);
}
void DayaBay::UserDataHeader::set ( const std::string &  name,
const std::vector< int > &  value 
) [inline]

Set a user-defined data name and value.

Definition at line 237 of file UserDataHeader.h.

{
this->setIntArray(name, value);
}
void DayaBay::UserDataHeader::set ( const std::string &  name,
const std::vector< float > &  value 
) [inline]

Set a user-defined data name and value.

Definition at line 243 of file UserDataHeader.h.

{
this->setFloatArray(name, value);
}
DayaBay::UserData * DayaBay::UserDataHeader::get ( const std::string &  name) [inline]

Get a user-defined data name and value.

Definition at line 249 of file UserDataHeader.h.

{

          DayaBay::UserDataHeader::UserDataList::iterator dataIter, 
            dataEnd = m_data.end();
          for(dataIter=m_data.begin(); dataIter!=dataEnd; dataIter++){
            if( (*dataIter)->name() == name ) return (*dataIter);
          }
          return 0;
         
}
std::ostream & DayaBay::UserDataHeader::fillStream ( std::ostream &  s) const [virtual]

Serialize to an ostream.

Reimplemented from DayaBay::HeaderObject.

Definition at line 30 of file UserDataHeader.cc.

{
    HeaderObject::fillStream(s);

    s << "{" << std::endl;
    s << "user-defined data :   [";
    for (size_t ind=0; ind<m_data.size(); ++ind) {
        s << " " << m_data[ind];
    }
    s << " ]" << std::endl;
    s << "}" << std::endl;

    return s;
}
const DayaBay::UserDataHeader::UserDataList & DayaBay::UserDataHeader::data ( ) const [inline]

Retrieve const List of user-defined data.

Definition at line 210 of file UserDataHeader.h.

{
  return m_data;
}
DayaBay::UserDataHeader::UserDataList & DayaBay::UserDataHeader::data ( ) [inline]

Retrieve List of user-defined data.

Definition at line 215 of file UserDataHeader.h.

{
  return m_data;
}
void DayaBay::UserDataHeader::setData ( const UserDataList value) [inline]

Update List of user-defined data.

Definition at line 220 of file UserDataHeader.h.

{
  m_data = value;
}
static void* DayaBay::UserDataHeader::operator new ( size_t  size) [inline, static]

operator new

Reimplemented from DayaBay::HeaderObject.

Definition at line 149 of file UserDataHeader.h.

    {
      return ( sizeof(UserDataHeader) == size ? 
               boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::malloc() :
               ::operator new(size) );
    }
static void* DayaBay::UserDataHeader::operator new ( size_t  size,
void *  pObj 
) [inline, static]

placement operator new it is needed by libstdc++ 3.2.3 (e.g.

in std::vector) it is not needed in libstdc++ >= 3.4

Reimplemented from DayaBay::HeaderObject.

Definition at line 159 of file UserDataHeader.h.

    {
      return ::operator new (size,pObj);
    }
static void DayaBay::UserDataHeader::operator delete ( void *  p) [inline, static]

operator delete

Reimplemented from DayaBay::HeaderObject.

Definition at line 165 of file UserDataHeader.h.

    {
      boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::is_from(p) ?
      boost::singleton_pool<UserDataHeader, sizeof(UserDataHeader)>::free(p) :
      ::operator delete(p);
    }
static void DayaBay::UserDataHeader::operator delete ( void *  p,
void *  pObj 
) [inline, static]

placement operator delete not sure if really needed, but it does not harm

Reimplemented from DayaBay::HeaderObject.

Definition at line 174 of file UserDataHeader.h.

    {
      ::operator delete (p, pObj);
    }

Member Data Documentation

List of user-defined data.

Definition at line 183 of file UserDataHeader.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:58:45 for UserData by doxygen 1.7.4