version  0.0.1
Defines the C++ API for MsPASS
Public Member Functions | List of all members
mspass::utility::AlgorithmDefinition Class Reference

Lightweight data structure to completely describe an algorithm. More...

#include <ProcessManager.h>

Public Member Functions

 AlgorithmDefinition ()
 
 AlgorithmDefinition (const std::string name, const std::string typin, const std::string typout, const std::string id)
 
 AlgorithmDefinition (const AlgorithmDefinition &parent)
 
std::string name () const
 
std::string id () const
 return the id as a string. More...
 
void set_id (const std::string id)
 
AlgorithmDefinitionoperator= (const AlgorithmDefinition &parent)
 

Detailed Description

Lightweight data structure to completely describe an algorithm.

Processing data always involves application of one or more algorithms. Most algorithms have one to many parameters that define the algorithm's detailed behavior. Because the size of parametric input can sometimes be huge MsPASS needed a way to carry a concise summary of algorithms applied to data. The issue is complicated by the fact that the same algorithm may be applied to data at diffrent stages with different parameters (e.g. bandpass filters applied before and after deconvolution). To address this problem we save input parameters for any instance of an algorithm in MongoDB as a document in the history collection. This implementation uses a simple string to define a particular instance. In the current implementation of MsPASS that is set as the string representation of the ObjectID defined for that document. An alternative would be UUID as used in TimeSeries and Seismogram objects, but we prefer the ObjectID string here as it is a guaranteed unique key by MongoDB, always has an index defined for the collection, and reduces the size of the history collection by not requiring a uuid attribute.

Any algorithm for which no optional parameters are needed will have the id field empty.

A special case is readers that act as origins from "raw" which may not literally be "raw" but is just a signal that a reader initiated a history chain. For readers input_type is set to "NotApplicable" and output_type is to be defined for that reader. Readers may or may not have control parameters.

Constructor & Destructor Documentation

◆ AlgorithmDefinition() [1/2]

mspass::utility::AlgorithmDefinition::AlgorithmDefinition ( )
inline

Default constructor.

This consructor is realy the same as what would be automatically generated. We define it to be clear and because I think pybind11 may need this declaration to allow a python wrapper for a default constructor.

51 : nm(),myid(),input_type(),output_type() {};

◆ AlgorithmDefinition() [2/2]

mspass::utility::AlgorithmDefinition::AlgorithmDefinition ( const std::string  name,
const std::string  typin,
const std::string  typout,
const std::string  id 
)
inline

Primary constructor.

This constructor sets the two primary attributes of this object. name is a descriptive (unique) name assigned to the algorithm and id is a unique id key. In MsPASS it is the string representation of the ObjectID assigned to the MongoDB document holding the parameter data that defines this instance of an algorithm.

Parameters
nameis the algorithm's (unique) name
idis a unique id string defining the parameters that were used for this instance of an algorithm.
66  {
67  nm=name;
68  myid=id;
69  input_type=typin;
70  output_type=typout;
71  };
std::string id() const
return the id as a string.
Definition: ProcessManager.h:90

References id().

Member Function Documentation

◆ id()

std::string mspass::utility::AlgorithmDefinition::id ( ) const
inline

return the id as a string.

In MsPASS the id is normally a MongoDB ObjectID string representation of the documnt saved in the database that holds the paramters defining a particular algorithm instance. If the algorithm has no parameters this string will be null. Callers should test that condition by calling the length method of std::string to verify the id is not zero length

91  {
92  return myid;
93  };

◆ set_id()

void mspass::utility::AlgorithmDefinition::set_id ( const std::string  id)
inline

Set a new id string.

The id straing is used to define a unique instance of an algorithm for a particular set of parameters. This is the only putter for this class because it is the only attribute that should ever be changed after construction. The reason is the name and type constraints are fixed, but id defines a particular instance that may be variable.

101 {myid=id;};

References id().


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