Xmipp  v3.23.11-Nereus
Classes | Public Types | Public Member Functions | Friends | List of all members
MDRow Class Referenceabstract

#include <metadata_row_base.h>

Inheritance diagram for MDRow:
Inheritance graph
[legend]

Classes

class  iterator_ptr
 

Public Types

using iterator = iterator_ptr< false >
 
using const_iterator = iterator_ptr< true >
 

Public Member Functions

virtual void detach ()
 
virtual bool empty () const =0
 
virtual int size () const =0
 
virtual void clear ()=0
 
virtual MDRowoperator= (const MDRow &)=0
 
virtual ~MDRow ()=default
 
virtual size_t id () const
 
virtual bool containsLabel (MDLabel label) const =0
 
virtual std::vector< MDLabellabels () const =0
 
virtual void addLabel (MDLabel label)=0
 
virtual void resetGeo (bool addLabels=true)
 
virtual MDObjectgetObject (MDLabel label)=0
 
virtual const MDObjectgetObject (MDLabel label) const =0
 
template<typename T >
T & getValue (MDLabel label)
 
template<typename T >
const T & getValue (MDLabel label) const
 
template<typename T >
bool getValue (MDLabel label, T &d) const
 
bool getValue (MDObject &object) const
 
template<typename T >
const T & getValueOrDefault (MDLabel label, const T &def) const
 
template<typename T >
T & getValueOrDefault (MDLabel label, const T &def)
 
template<typename T , typename T1 >
void getValueOrDefault (MDLabel label, T &d, T1 def) const
 
template<typename T >
void setValue (MDLabel label, const T &d, bool addLabel=true)
 
virtual void setValue (const MDObject &object)=0
 
virtual void setValueFromStr (MDLabel label, const String &value)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Friends

std::ostream & operator<< (std::ostream &out, const MDRow &row)
 

Detailed Description

Common API of all metadata rows (abstract class). Classes like MDRowVec & MDRowSql implement this API.

Definition at line 53 of file metadata_row_base.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 191 of file metadata_row_base.h.

◆ iterator

using MDRow::iterator = iterator_ptr<false>

Definition at line 190 of file metadata_row_base.h.

Constructor & Destructor Documentation

◆ ~MDRow()

virtual MDRow::~MDRow ( )
virtualdefault

Member Function Documentation

◆ addLabel()

virtual void MDRow::addLabel ( MDLabel  label)
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ begin() [1/2]

iterator MDRow::begin ( )
inline

Definition at line 193 of file metadata_row_base.h.

193 { return iterator_ptr<false>(0, *this); }

◆ begin() [2/2]

const_iterator MDRow::begin ( ) const
inline

Definition at line 196 of file metadata_row_base.h.

196 { return iterator_ptr<true>(0, *this); }

◆ clear()

virtual void MDRow::clear ( )
pure virtual

Return number of labels present

Implemented in MDRowVec, and MDRowSql.

◆ containsLabel()

virtual bool MDRow::containsLabel ( MDLabel  label) const
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ detach()

virtual void MDRow::detach ( )
inlinevirtual

Reimplemented in MDRowVec.

Definition at line 58 of file metadata_row_base.h.

58 {}

◆ empty()

virtual bool MDRow::empty ( ) const
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ end() [1/2]

iterator MDRow::end ( )
inline

Definition at line 194 of file metadata_row_base.h.

194 { return iterator_ptr<false>(this->size(), *this); }
virtual int size() const =0

◆ end() [2/2]

const_iterator MDRow::end ( ) const
inline

Definition at line 197 of file metadata_row_base.h.

197 { return iterator_ptr<true>(this->size(), *this); }
virtual int size() const =0

◆ getObject() [1/2]

virtual MDObject* MDRow::getObject ( MDLabel  label)
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ getObject() [2/2]

virtual const MDObject* MDRow::getObject ( MDLabel  label) const
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ getValue() [1/4]

template<typename T >
T& MDRow::getValue ( MDLabel  label)
inline

Definition at line 97 of file metadata_row_base.h.

97  {
98  MDObject* ptr = getObject(label);
99  if (ptr == nullptr)
100  throw std::logic_error("Object does not exist!");
101  return ptr->getValue2(T());
102  }
const int & getValue2(int) const
virtual MDObject * getObject(MDLabel label)=0

◆ getValue() [2/4]

template<typename T >
const T& MDRow::getValue ( MDLabel  label) const
inline

Definition at line 105 of file metadata_row_base.h.

105  {
106  const MDObject* ptr = getObject(label);
107  if (ptr == nullptr)
108  throw std::logic_error("Object does not exist!");
109  return ptr->getValue2(T());
110  }
const int & getValue2(int) const
virtual MDObject * getObject(MDLabel label)=0

◆ getValue() [3/4]

template<typename T >
bool MDRow::getValue ( MDLabel  label,
T &  d 
) const
inline

Definition at line 113 of file metadata_row_base.h.

113  { // FIXME: deprecated
114  auto *obj = getObject(label);
115  if (obj == nullptr)
116  return false;
117  d = obj->getValue2(T());
118  return true;
119  }
doublereal * d
void(* obj)()
virtual MDObject * getObject(MDLabel label)=0

◆ getValue() [4/4]

bool MDRow::getValue ( MDObject object) const
inline

Definition at line 121 of file metadata_row_base.h.

121  { // FIXME: deprecated
122  const MDObject* ptr = this->getObject(object.label);
123  if (ptr != nullptr)
124  object = *ptr;
125  return (ptr != nullptr);
126  }
virtual MDObject * getObject(MDLabel label)=0

◆ getValueOrDefault() [1/3]

template<typename T >
const T& MDRow::getValueOrDefault ( MDLabel  label,
const T &  def 
) const
inline

Definition at line 129 of file metadata_row_base.h.

129  {
130  const MDObject* ptr = getObject(label);
131  if (ptr == nullptr)
132  return def;
133  return ptr->getValue2(T());
134  }
const int & getValue2(int) const
virtual MDObject * getObject(MDLabel label)=0

◆ getValueOrDefault() [2/3]

template<typename T >
T& MDRow::getValueOrDefault ( MDLabel  label,
const T &  def 
)
inline

Definition at line 137 of file metadata_row_base.h.

137  {
138  const MDObject* ptr = getObject(label);
139  if (ptr == nullptr)
140  return def;
141  return ptr->getValue2(T());
142  }
const int & getValue2(int) const
virtual MDObject * getObject(MDLabel label)=0

◆ getValueOrDefault() [3/3]

template<typename T , typename T1 >
void MDRow::getValueOrDefault ( MDLabel  label,
T &  d,
T1  def 
) const
inline

Definition at line 145 of file metadata_row_base.h.

145  { // FIXME: deprecated
146  if (!getValue(label, d))
147  d = (T) def;
148  }
doublereal * d
T & getValue(MDLabel label)

◆ id()

virtual size_t MDRow::id ( ) const
inlinevirtual

Reimplemented in MDRowSql.

Definition at line 67 of file metadata_row_base.h.

67  {
68  return getObject(MDL_OBJID)->getValue2(size_t());
69  }
object id (int), NOTE: This label is special and shouldn&#39;t be used
const int & getValue2(int) const
virtual MDObject * getObject(MDLabel label)=0

◆ labels()

virtual std::vector<MDLabel> MDRow::labels ( ) const
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ operator=()

virtual MDRow& MDRow::operator= ( const MDRow )
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ resetGeo()

virtual void MDRow::resetGeo ( bool  addLabels = true)
inlinevirtual

Reset the values of the labels related to geometry to their default values

Definition at line 78 of file metadata_row_base.h.

78  {
89  setValue(MDL_FLIP, false, addLabels);
91  }
Rotation angle of an image (double,degrees)
void addLabels(PyObject *dict)
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
Special label to be used when gathering MDs in MpiMetadataPrograms.
auxiliary label to be used as an index (long)
Origin for the image in the Y axis (double)
Flip the image? (bool)
scaling factor for an image or volume (double)
void setValue(MDLabel label, const T &d, bool addLabel=true)
Shift for the image in the Z axis (double)
Origin for the image in the Z axis (double)
Shift for the image in the Y axis (double)
< Score 4 for volumes

◆ setValue() [1/2]

template<typename T >
void MDRow::setValue ( MDLabel  label,
const T &  d,
bool  addLabel = true 
)
inline

Definition at line 151 of file metadata_row_base.h.

151  {
152  if (this->containsLabel(label) || addLabel)
153  this->setValue(MDObject(label, d));
154  }
doublereal * d
virtual void addLabel(MDLabel label)=0
void setValue(MDLabel label, const T &d, bool addLabel=true)
virtual bool containsLabel(MDLabel label) const =0

◆ setValue() [2/2]

virtual void MDRow::setValue ( const MDObject object)
pure virtual

Implemented in MDRowVec, and MDRowSql.

◆ setValueFromStr()

virtual void MDRow::setValueFromStr ( MDLabel  label,
const String value 
)
inlinevirtual

Definition at line 158 of file metadata_row_base.h.

158  {
159  MDObject mdValue(label);
160  mdValue.fromString(value);
161  setValue(mdValue);
162  }
void setValue(MDLabel label, const T &d, bool addLabel=true)

◆ size()

virtual int MDRow::size ( ) const
pure virtual

Implemented in MDRowVec, and MDRowSql.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const MDRow row 
)
friend

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