Data entry (IdsNs::IDS) API¶
-
class IDS¶
Class modeling Data Entries.
Existing Data entries can be opened (see
open()andopenEnv()) and new ones created (seeopen()andcreateEnv()).All available IDSs are member classes in the scope of this class, e.g.
IdsNs::IDS::core_profiles.-
IDS()¶
Constructor to use with IMAS Data Entry URIs. Use
open()afterwards to open or create the Data Entry.
-
IDS(int pulse, int run, int refPulse, int refRun)¶
Constructor when not using IMAS Data Entry URIs. Use
openEnv()orcreateEnv()afterwards to open or create the Data Entry.
-
int open(const char *uri, int mode)¶
Open or create the Data Entry at the provided URI.
- Parameters:
- const char *uri¶
- int mode¶
One of
OPEN_PULSE,FORCE_OPEN_PULSE,CREATE_PULSEorFORCE_CREATE_PULSE.
- Returns:
Status code:
0on success,<0on failure.- Example:
-
int openEnv(const char *user, const char *tokamak, const char *version, const char *option)¶
Open the Data Entry defined by
pulse,run(seeIDS::IDS()) and the provided parameters.- Parameters:
- Returns:
Status code:
0on success,<0on failure- Example:
-
int createEnv(const char *user, const char *tokamak, const char *version, const char *option)¶
Create the Data Entry defined by
pulse,run(seeIDS::IDS()) and the provided parameters.
-
void setBackend(BACKEND inBackend)¶
Use the specified backend instead of the default one. Must be set before a call to
openEnv()orcreateEnv().
-
int getPulseCtx()¶
Get the pulse context ID opened/created by this Data Entry.
- Returns:
Pulse context ID.
See also
Ids::setPulseCtx()
-
int list_all_occurrences(int idx, const char *ids_name, const char *node_path, std::vector<string> &node_content_list, std::vector<int> &occurrence_list);¶
Give all occurrences list of the matching node and given IDS. If node_path is an empty string or null, only occurrence_list is relevant.
- Parameters:
- Returns:
Status code:
0on success,<0on failure- Example:
// Include the Access Layer #include "ALClasses.h" #include <iostream> int main(int argc, char *argv[]) { // Create a new IDS object IdsNs::IDS ids; std::vector<string> node_content_list; std::vector<int> occurrence_list; int status; // Open the database entry by providing an IMAS URI ids.open("imas:mdsplus?user=public;pulse=131024;run=41;database=ITER;version=3", OPEN_PULSE); // get all occurrence of all "ids_properties/comment" of each 'distributions' IDS status = IdsNs::IDS::list_all_occurrences(ids.getPulseCtx(), "distributions", "ids_properties/comment", node_content_list, occurrence_list); if (status==0) for (int i = 0; i < node_content_list.size(); i ++) std::cout << i << " " << occurrence_list[i] << " " << node_content_list[i] << std::endl; return 0; }
-
IDS()¶
-
al_status_t al_build_uri_from_legacy_parameters(const int backendID, const int pulse, const int run, const std::string user, const std::string tokamak, const std::string version, const std::string options, std::string &uri)¶
Build an URI string using legacy parameters.
- Parameters:
- const int backendID¶
Backend to use
- const int pulse¶
Pulse number
- const int run¶
Run number
- const std::string user¶
User name
- const std::string tokamak¶
Tokamak name, also known as Database name
- const std::string version¶
Major version of the data dictionary, e.g.
"3"- const std::string options¶
Options to pass to the backend
- std::string &uri¶
String with URI
- Returns:
al_status_t structure containing code and message fields. Code
0on success.- Example:
#include "ALClasses.h" #include <string> using namespace IdsNs; int main(int argc, char *argv[]) { al_status_t al_status; int pulse = 54; int run = 1234; std::string uri; std::string user = "public"; std::string database = "test"; std::string version = "3"; std::string options = ""; al_status = al_build_uri_from_legacy_parameters(MDSPLUS_BACKEND, pulse, run, user, database, version, options, uri); std::cout << al_status.code; return 0; }
-
al_status_t al_build_uri_from_legacy_parameters(const int backendID, const int pulse, const int run, const char *user, const char *tokamak, const char *version, const char *options, char **uri)¶
Build an URI string using legacy parameters.
- Parameters:
- const int backendID¶
Backend to use
- const int pulse¶
Pulse number
- const int run¶
Run number
- const char *user¶
User name
- const char *tokamak¶
Tokamak name, also known as Database name
- const char *version¶
Major version of the data dictionary, e.g.
"3"- const char *options¶
Options to pass to the backend
- char **uri¶
Char array with URI
- Returns:
al_status_t structure containing code and message fields. Code
0on success.- Example:
#include "ALClasses.h" #include <string> using namespace IdsNs; int main(int argc, char *argv[]) { al_status_t al_status; int pulse = 54; int run = 1234; char* uri; char* user = "public"; char* database = "test"; char* version = "3"; char* options = ""; al_status = al_build_uri_from_legacy_parameters(MDSPLUS_BACKEND, pulse, run, user, database, version, options, &uri); std::cout << al_status.code; return 0; }