JANA2
C++ framework for multi-threaded data processing
Loading...
Searching...
No Matches
JDatabundle Class Referenceabstract
Inheritance diagram for JDatabundle:
[legend]

Classes

struct  NoTypeProvided
 

Public Types

enum class  Status {
  Empty ,
  Created ,
  Inserted ,
  Excepted
}
 

Public Member Functions

 JDatabundle (const JDatabundle &other)
 
virtual size_t GetSize () const =0
 
virtual void ClearData ()=0
 
Status GetStatus () const
 
std::string GetUniqueName () const
 
std::string GetShortName () const
 
bool HasShortName () const
 
std::string GetTypeName () const
 
std::type_index GetTypeIndex () const
 
JCallGraphRecorder::JDataOrigin GetInsertOrigin () const
 If objects were placed here by JEvent::Insert() this records whether that call was made from a source or factory.
 
JFactoryGetFactory () const
 
void SetStatus (Status s)
 
void SetUniqueName (std::string unique_name)
 
void SetShortName (std::string short_name)
 
void SetTypeName (std::string type_name)
 
void SetTypeIndex (std::type_index index)
 
void SetInsertOrigin (JCallGraphRecorder::JDataOrigin origin)
 Called automatically by JEvent::Insert() to records whether that call was made by a source or factory.
 
void SetFactory (JFactory *fac)
 
template<typename S >
std::vector< S * > GetAs ()
 Generically access the encapsulated data, performing an upcast if necessary.
 

Protected Attributes

std::unordered_map< std::type_index, std::unique_ptr< JAny > > mUpcastVTable
 

Member Function Documentation

◆ GetAs()

template<typename S >
std::vector< S * > JDatabundle::GetAs ( )

Generically access the encapsulated data, performing an upcast if necessary.

This is useful for extracting data from all JFactories<T> where T extends a parent class S, such as JObject or TObject, in contexts where T is not known or it would introduce an unwanted coupling. The main application is for building DSTs.

Be aware of the following caveats:

  • The factory's object type must not use virtual inheritance.
  • If JFactory::Process hasn't already been called, this will return an empty vector. This will NOT call JFactory::Process.
  • Someone must call JFactoryT<T>::EnableGetAs<S>, preferably the constructor. Otherwise, this will return an empty vector.
  • If S isn't a base class of T, this will return an empty vector.

The documentation for this class was generated from the following file: