Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
MDMultiQuery Class Reference

#include <metadata_query.h>

Inheritance diagram for MDMultiQuery:
Inheritance graph
[legend]
Collaboration diagram for MDMultiQuery:
Collaboration graph
[legend]

Public Member Functions

 MDMultiQuery (int limit=-1, int offset=0, MDLabel orderLabel=MDL_OBJID)
 
void addAndQuery (MDQuery &query)
 
void addOrQuery (MDQuery &query)
 
void clear ()
 
virtual String queryStringFunc () const
 
- Public Member Functions inherited from MDQuery
 MDQuery (int limit=-1, int offset=0, MDLabel orderLabel=MDL_OBJID, bool asc=true)
 
virtual ~MDQuery ()
 
String orderByString () const
 
String limitString () const
 
String whereString () const
 

Public Attributes

std::vector< const MDQuery * > queries
 
std::vector< Stringoperations
 
- Public Attributes inherited from MDQuery
int limit
 If distint of -1 the results will be limited to this value. More...
 
int offset
 If distint of 0, offset elements will be discarded. More...
 
MDLabel orderLabel
 Label to which apply sort of the results. More...
 
bool asc
 

Detailed Description

Query several conditions using AND and OR. This kind of query if useful if you want to check two conditions at the same time, for example, import all images that are enabled and have rotational angle greater than 100.

MetaData md1, md2;
//The first query added has the same effect doing with AND or OR
multi.addAndQuery(eq);
multi.addAndQuery(gt);
md1.importObjects(md2, multi);

Definition at line 334 of file metadata_query.h.

Constructor & Destructor Documentation

◆ MDMultiQuery()

MDMultiQuery::MDMultiQuery ( int  limit = -1,
int  offset = 0,
MDLabel  orderLabel = MDL_OBJID 
)
inline

Definition at line 340 of file metadata_query.h.

341  {
342  clear();
343  }
int limit
If distint of -1 the results will be limited to this value.
MDLabel orderLabel
Label to which apply sort of the results.
int offset
If distint of 0, offset elements will be discarded.
MDQuery(int limit=-1, int offset=0, MDLabel orderLabel=MDL_OBJID, bool asc=true)

Member Function Documentation

◆ addAndQuery()

void MDMultiQuery::addAndQuery ( MDQuery query)
inline

Definition at line 344 of file metadata_query.h.

345  {
346  queries.emplace_back(&query);
347  operations.emplace_back("AND");
348  }
std::vector< String > operations
std::vector< const MDQuery * > queries

◆ addOrQuery()

void MDMultiQuery::addOrQuery ( MDQuery query)
inline

Definition at line 349 of file metadata_query.h.

350  {
351  queries.emplace_back(&query);
352  operations.emplace_back("OR");
353  }
std::vector< String > operations
std::vector< const MDQuery * > queries

◆ clear()

void MDMultiQuery::clear ( )
inline

Definition at line 355 of file metadata_query.h.

356  {
357  queries.clear();
358  operations.clear();
359  }
std::vector< String > operations
std::vector< const MDQuery * > queries

◆ queryStringFunc()

String MDMultiQuery::queryStringFunc ( ) const
virtual

Return the query string, should be overrided in subclasses

Reimplemented from MDQuery.

Definition at line 22 of file metadata_query.cpp.

23 {
24  if (queries.size() > 0)
25  {
26  std::stringstream ss;
27  ss << "(" << queries[0]->queryStringFunc() << ") ";
28  for (size_t i = 1; i < queries.size(); i++)
29  ss << operations[i] << " (" << queries[i]->queryStringFunc() << ") ";
30 
31  return ss.str();
32  }
33  return " ";
34 }
std::vector< String > operations
#define i
std::vector< const MDQuery * > queries
virtual String queryStringFunc() const

Member Data Documentation

◆ operations

std::vector<String> MDMultiQuery::operations

Definition at line 338 of file metadata_query.h.

◆ queries

std::vector<const MDQuery*> MDMultiQuery::queries

Definition at line 337 of file metadata_query.h.


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