MIDAS
|
Classes | |
struct | db_err_msg_struct |
struct | print_key_info_buf |
struct | UPDATE_OPEN_RECORDS |
Macros | |
#define | CHECK_OPEN_RECORD 1 |
#define | HAVE_DB_GET_VALUE_STRING_CREATE_STRING_LENGTH 1 |
Typedefs | |
typedef struct db_err_msg_struct | db_err_msg |
dox
Definition at line 620 of file odb.cxx.
Definition at line 12734 of file odb.cxx.
dox
Definition at line 12363 of file odb.cxx.
Definition at line 2548 of file odb.cxx.
Check if a client with a /system/client/xxx entry has a valid entry in the ODB client table. If not, remove that client from the /system/client tree.
hDB | Handle to online database |
hKeyClient | Handle to client key |
Definition at line 3059 of file odb.cxx.
INT EXPRT db_check_record | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const char * | keyname, | ||
const char * | rec_str, | ||
BOOL | correct | ||
) |
This function ensures that a certain ODB subtree matches a given C structure, by comparing the init_str with the current ODB structure. If the record does not exist at all, it is created with the default values in init_str. If it does exist but does not match the variables in init_str, the function returns an error if correct=FALSE or calls db_create_record() if correct=TRUE.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
keyname | Name of key to search, can contain directories. |
rec_str | ASCII representation of ODB record in the format |
correct | If TRUE, correct ODB record if necessary |
Definition at line 12972 of file odb.cxx.
|
static |
Definition at line 7148 of file odb.cxx.
|
static |
Definition at line 7101 of file odb.cxx.
Definition at line 2827 of file odb.cxx.
void db_cleanup2 | ( | const char * | client_name, |
int | ignore_timeout, | ||
DWORD | actual_time, | ||
const char * | who | ||
) |
Definition at line 2897 of file odb.cxx.
Definition at line 2360 of file odb.cxx.
Release local memory for open records. This routines is called by db_close_all_databases() and cm_disconnect_experiment()
Definition at line 13514 of file odb.cxx.
Close a database
hDB | ODB handle obtained via cm_get_experiment_database(). |
Definition at line 2152 of file odb.cxx.
Close a record previously opend with db_open_record.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
Definition at line 13473 of file odb.cxx.
Copy an ODB subtree in ASCII format to a buffer
This function converts the binary ODB contents to an ASCII. The function db_paste() can be used to convert the ASCII representation back to binary ODB contents. The functions db_load() and db_save() internally use db_copy() and db_paste(). This function converts the binary ODB contents to an ASCII representation of the form:
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
buffer | ASCII buffer which receives ODB contents. |
buffer_size | Size of buffer, returns remaining space in buffer. |
path | Internal use only, must be empty (""). |
Definition at line 8217 of file odb.cxx.
INT EXPRT db_copy_json_array | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end | ||
) |
Copy an ODB array in JSON format to a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key |
buffer | returns pointer to ASCII buffer with ODB contents |
buffer_size | returns size of ASCII buffer |
buffer_end | returns number of bytes contained in buffer |
Definition at line 10150 of file odb.cxx.
INT EXPRT db_copy_json_index | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
int | index, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end | ||
) |
Copy an ODB array element in JSON format to a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key |
index | Array index |
buffer | returns pointer to ASCII buffer with ODB contents |
buffer_size | returns size of ASCII buffer |
buffer_end | returns number of bytes contained in buffer |
Definition at line 10219 of file odb.cxx.
INT EXPRT db_copy_json_ls | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end | ||
) |
Definition at line 10421 of file odb.cxx.
INT EXPRT db_copy_json_obsolete | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end, | ||
int | save_keys, | ||
int | follow_links, | ||
int | recurse | ||
) |
Copy an ODB subtree in JSON format to a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
buffer | returns pointer to ASCII buffer with ODB contents |
buffer_size | returns size of ASCII buffer |
buffer_end | returns number of bytes contained in buffer |
Definition at line 10508 of file odb.cxx.
INT EXPRT db_copy_json_save | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end | ||
) |
Definition at line 10475 of file odb.cxx.
INT EXPRT db_copy_json_values | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end, | ||
int | omit_names, | ||
int | omit_last_written, | ||
time_t | omit_old_timestamp, | ||
int | preserve_case | ||
) |
Definition at line 10443 of file odb.cxx.
Copy an ODB subtree in XML format to a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
buffer | ASCII buffer which receives ODB contents. |
buffer_size | Size of buffer, returns remaining space in buffer. |
Definition at line 9037 of file odb.cxx.
Create a new key in a database
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Key handle to start with, 0 for root |
key_name | Name of key in the form "/key/key/key" |
type | Type of key, one of TID_xxx (see Midas_Data_Types) |
Definition at line 3308 of file odb.cxx.
|
static |
Definition at line 3364 of file odb.cxx.
INT EXPRT db_create_link | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const char * | link_name, | ||
const char * | destination | ||
) |
Create a link to a key or set the destination of and existing link.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Key handle to start with, 0 for root |
link_name | Name of key in the form "/key/key/key" |
destination | Destination of link in the form "/key/key/key" |
Definition at line 3601 of file odb.cxx.
INT EXPRT db_create_record | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const char * | orig_key_name, | ||
const char * | init_str | ||
) |
dox Create a record. If a part of the record exists alreay, merge it with the init_str (use values from the init_str only when they are not in the existing record).
This functions creates a ODB sub-tree according to an ASCII representation of that tree. See db_copy() for a description. It can be used to create a sub-tree which exactly matches a C structure. The sub-tree can then later mapped to the C structure ("hot-link") via the function db_open_record().
If a sub-tree exists already which exactly matches the ASCII representation, it is not modified. If part of the tree exists, it is merged with the ASCII representation where the ODB values have priority, only values not present in the ODB are created with the default values of the ASCII representation. It is therefore recommended that before creating an ODB hot-link the function db_create_record() is called to insure that the ODB tree and the C structure contain exactly the same values in the same order.
Following example creates a record under /Equipment/Trigger/Settings, opens a hot-link between that record and a local C structure trigger_settings and registers a callback function trigger_update() which gets called each time the record is changed.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
orig_key_name | Name of key to search, can contain directories. |
init_str | Initialization string in the format of the db_copy/db_save functions. |
Definition at line 12800 of file odb.cxx.
Delete client info from database
hDB | Database handle |
pid | PID of entry to delete, zero for this process. |
Definition at line 2791 of file odb.cxx.
|
static |
Definition at line 2760 of file odb.cxx.
|
static |
Definition at line 2725 of file odb.cxx.
Delete a subtree in a database starting from a key (including this key).
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | for key where search starts, zero for root. |
follow_links | Follow links when TRUE. |
Definition at line 3856 of file odb.cxx.
Delete a subtree, using level information (only called internally by db_delete_key())
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Key handle to start with, 0 for root |
level | Recursion level, must be zero when |
follow_links | Follow links when TRUE called from a user routine |
Definition at line 3669 of file odb.cxx.
|
static |
Definition at line 1056 of file odb.cxx.
Enumerate subkeys from a key, follow links.
hkey must correspond to a valid ODB directory. The index is usually incremented in a loop until the last key is reached. Information about the sub-keys can be obtained with db_get_key(). If a returned key is of type TID_KEY, it contains itself sub-keys. To scan a whole ODB sub-tree, the function db_scan_tree() can be used.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
idx | Subkey index, sould be initially 0, then incremented in each call until subhKey becomes zero and the function returns DB_NO_MORE_SUBKEYS |
subkey_handle | Handle of subkey which can be used in db_get_key() and db_get_data() |
Definition at line 5586 of file odb.cxx.
dox
Definition at line 5725 of file odb.cxx.
|
static |
Returns key handle for a key with a specific name.
Keys can be accessed by their name including the directory or by a handle. A key handle is an internal offset to the shared memory where the ODB lives and allows a much faster access to a key than via its name.
The function db_find_key() must be used to convert a key name to a handle. Most other database functions use this key handle in various operations.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
key_name | Name of key to search, can contain directories. |
subhKey | Returned handle of key, zero if key cannot be found. |
Definition at line 4079 of file odb.cxx.
dox
Definition at line 4125 of file odb.cxx.
|
static |
INT EXPRT db_find_keys | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
char * | odbpath, | ||
std::vector< HNDLE > & | hKeyVector | ||
) |
Definition at line 4586 of file odb.cxx.
Definition at line 4274 of file odb.cxx.
Definition at line 4439 of file odb.cxx.
|
static |
Definition at line 5104 of file odb.cxx.
|
static |
Definition at line 3865 of file odb.cxx.
|
static |
Definition at line 5146 of file odb.cxx.
dox
Definition at line 2268 of file odb.cxx.
|
static |
Definition at line 167 of file odb.cxx.
dox Get key data from a handle
The function returns single values or whole arrays which are contained in an ODB key. Since the data buffer is of type void, no type checking can be performed by the compiler. Therefore the type has to be explicitly supplied, which is checked against the type stored in the ODB.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to the return data. |
buf_size | Size of data buffer. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 6539 of file odb.cxx.
INT EXPRT db_get_data1 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | data, | ||
INT * | buf_size, | ||
DWORD | type, | ||
INT * | num_values | ||
) |
dox
Definition at line 6756 of file odb.cxx.
INT EXPRT db_get_data_index | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | data, | ||
INT * | buf_size, | ||
INT | idx, | ||
DWORD | type | ||
) |
dox returns a single value of keys containing arrays of values.
The function returns a single value of keys containing arrays of values.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Size of data buffer. |
buf_size | Return size of the record. |
idx | Index of array [0..n-1]. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 6893 of file odb.cxx.
|
static |
Definition at line 5506 of file odb.cxx.
Definition at line 786 of file odb.cxx.
Get key structure from a handle.
KEY structure has following format:
Most of these values are used for internal purposes, the values which are of public interest are type, name, num_values, item_size and total_size. For keys which contain a single value, num_values equals to one and total_size equals to item_size. For keys which contain an array of strings (TID_STRING), item_size equals to the length of one string.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. If Key is a link to an array element, this link is resolved. In this case function returns the key of the link destination and num_values is set to 1. |
key | Pointer to KEY stucture. |
Definition at line 6019 of file odb.cxx.
INT EXPRT db_get_key_info | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char * | name, | ||
INT | name_size, | ||
INT * | type, | ||
INT * | num_values, | ||
INT * | item_size | ||
) |
Get key info (separate values instead of structure)
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle of key to operate on |
name | Key name |
name_size | Size of the give name (done with sizeof()) |
type | Key type (see Midas_Data_Types). |
num_values | Number of values in key. |
item_size | Size of individual key value (used for strings) |
Definition at line 6191 of file odb.cxx.
|
static |
Get time when key was last modified
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle of key to operate on |
delta | Seconds since last update |
Definition at line 6132 of file odb.cxx.
Same as db_get_key, but it does not follow links
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
key | Pointer to KEY stucture. |
Definition at line 6072 of file odb.cxx.
Same as db_get_data, but do not follow a link to an array index
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to the return data. |
buf_size | Size of data buffer. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 6656 of file odb.cxx.
DATABASE_CLIENT * db_get_my_client_locked | ( | DATABASE * | pdb | ) |
Definition at line 1365 of file odb.cxx.
Definition at line 5816 of file odb.cxx.
Definition at line 5188 of file odb.cxx.
|
static |
Definition at line 1030 of file odb.cxx.
Definition at line 4699 of file odb.cxx.
Definition at line 5049 of file odb.cxx.
Definition at line 4990 of file odb.cxx.
|
static |
Definition at line 4901 of file odb.cxx.
|
static |
Definition at line 4962 of file odb.cxx.
|
static |
Definition at line 930 of file odb.cxx.
|
static |
Definition at line 982 of file odb.cxx.
Copy a set of keys to local memory.
An ODB sub-tree can be mapped to a C structure automatically via a hot-link using the function db_open_record() or manually with this function. Problems might occur if the ODB sub-tree contains values which don't match the C structure. Although the structure size is checked against the sub-tree size, no checking can be done if the type and order of the values in the structure are the same than those in the ODB sub-tree. Therefore it is recommended to use the function db_create_record() before db_get_record() is used which ensures that both are equivalent.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to the retrieved data. |
buf_size | Size of data structure, must be obtained via sizeof(RECORD-NAME). |
align | Byte alignment calculated by the stub and passed to the rpc side to align data according to local machine. Must be zero when called from user level. |
Definition at line 11709 of file odb.cxx.
INT EXPRT db_get_record1 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | data, | ||
INT * | buf_size, | ||
INT | align, | ||
const char * | rec_str | ||
) |
Same as db_get_record() but if there is a record mismatch between ODB structure and C record, it is automatically corrected by calling db_check_record()
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to the retrieved data. |
buf_size | Size of data structure, must be obtained via sizeof(RECORD-NAME). |
align | Byte alignment calculated by the stub and passed to the rpc side to align data according to local machine. Must be zero when called from user level. |
rec_str | ASCII representation of ODB record in the format |
Definition at line 11805 of file odb.cxx.
INT EXPRT db_get_record2 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | data, | ||
INT * | xbuf_size, | ||
INT | align, | ||
const char * | rec_str, | ||
BOOL | correct | ||
) |
Copy a set of keys to local memory.
An ODB sub-tree can be mapped to a C structure automatically via a hot-link using the function db_open_record1() or manually with this function. For correct operation, the description string must match the C data structure. If the contents of ODB sub-tree does not exactly match the description string, db_get_record2() will try to read as much as it can and return DB_TRUNCATED to inform the user that there was a mismatch somewhere. To ensure that the ODB sub-tree matches the desciption string, call db_create_record() or db_check_record() before calling db_get_record2(). Unlike db_get_record() and db_get_record1(), this function will not complain about data strucure mismatches. It will ignore all extra entries in the ODB sub-tree and it will set to zero the C-structure data fields that do not have corresponding ODB entries.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to the retrieved data. |
buf_size | Size of data structure, must be obtained via sizeof(data). |
align | Byte alignment calculated by the stub and passed to the rpc side to align data according to local machine. Must be zero when called from user level. |
rec_str | Description of the data structure, see db_create_record() |
correct | Must be set to zero |
Definition at line 12169 of file odb.cxx.
|
static |
Definition at line 12049 of file odb.cxx.
dox Calculates the size of a record.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
align | Byte alignment calculated by the stub and passed to the rpc side to align data according to local machine. Must be zero when called from user level |
buf_size | Size of record structure |
Definition at line 11615 of file odb.cxx.
INT EXPRT db_get_value | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
void * | data, | ||
INT * | buf_size, | ||
DWORD | type, | ||
BOOL | create | ||
) |
Get value of a single key.
The function returns single values or whole arrays which are contained in an ODB key. Since the data buffer is of type void, no type checking can be performed by the compiler. Therefore the type has to be explicitly supplied, which is checked against the type stored in the ODB. key_name can contain the full path of a key (like: "/Equipment/Trigger/Settings/Level1") while hkey is zero which refers to the root, or hkey can refer to a sub-directory (like: /Equipment/Trigger) and key_name is interpreted relative to that directory like "Settings/Level1".
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
key_name | Name of key to search, can contain directories. |
data | Address of data. |
buf_size | Maximum buffer size on input, number of written bytes on return. |
type | Type of key, one of TID_xxx (see Midas_Data_Types) |
create | If TRUE, create key if not existing |
Definition at line 5415 of file odb.cxx.
INT EXPRT db_get_value_string | ( | HNDLE | hdb, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
int | index, | ||
std::string * | s, | ||
BOOL | create, | ||
int | create_string_length | ||
) |
Definition at line 13934 of file odb.cxx.
Return watchdog information about specific client
hDB | ODB handle |
client_name | ODB client name |
timeout | Timeout for this application in seconds |
last | Last time watchdog was called in msec |
Definition at line 3014 of file odb.cxx.
dox Load a branch of a database from an .ODB file.
This function is used by the ODBEdit command load. For a description of the ASCII format, see db_copy(). Data can be loaded relative to the root of the ODB (hkey equal zero) or relative to a certain key.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
filename | Filename of .ODB file. |
bRemote | If TRUE, the file is loaded by the server process on the back-end, if FALSE, it is loaded from the current process |
Definition at line 8126 of file odb.cxx.
Definition at line 15 of file json_paste.cxx.
dox Lock a database for exclusive access via system semaphore calls.
hDB | Handle to the database to lock |
Definition at line 2455 of file odb.cxx.
INT EXPRT db_merge_data | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
const char * | name, | ||
void * | data, | ||
INT | data_size, | ||
INT | num_values, | ||
INT | type | ||
) |
Definition at line 7928 of file odb.cxx.
|
static |
Definition at line 121 of file odb.cxx.
Definition at line 12594 of file odb.cxx.
Definition at line 12623 of file odb.cxx.
|
static |
Definition at line 12539 of file odb.cxx.
INT EXPRT db_open_database | ( | const char * | xdatabase_name, |
INT | database_size, | ||
HNDLE * | hDB, | ||
const char * | client_name | ||
) |
dox Open an online database
database_name | Database name. |
database_size | Initial size of database if not existing |
client_name | Name of this application |
hDB | ODB handle obtained via cm_get_experiment_database(). |
Definition at line 1787 of file odb.cxx.
INT EXPRT db_open_record | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | ptr, | ||
INT | rec_size, | ||
WORD | access_mode, | ||
void(*)(INT, INT, void *) | dispatcher, | ||
void * | info | ||
) |
Open a record. Create a local copy and maintain an automatic update.
This function opens a hot-link between an ODB sub-tree and a local structure. The sub-tree is copied to the structure automatically every time it is modified by someone else. Additionally, a callback function can be declared which is called after the structure has been updated. The callback function receives the database handle and the key handle as parameters.
Problems might occur if the ODB sub-tree contains values which don't match the C structure. Although the structure size is checked against the sub-tree size, no checking can be done if the type and order of the values in the structure are the same than those in the ODB sub-tree. Therefore it is recommended to use the function db_create_record() before db_open_record() is used which ensures that both are equivalent.
The access mode might either be MODE_READ or MODE_WRITE. In read mode, the ODB sub-tree is automatically copied to the local structure when modified by other clients. In write mode, the local structure is copied to the ODB sub-tree if it has been modified locally. This update has to be manually scheduled by calling db_send_changed_records() periodically in the main loop. The system keeps a copy of the local structure to determine if its contents has been changed.
If MODE_ALLOC is or'ed with the access mode, the memory for the structure is allocated internally. The structure pointer must contain a pointer to a pointer to the structure. The internal memory is released when db_close_record() is called.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
ptr | If access_mode includes MODE_ALLOC: Address of pointer which points to the record data after the call if access_mode includes not MODE_ALLOC: Address of record if ptr==NULL, only the dispatcher is called. |
rec_size | Record size in bytes |
access_mode | Mode for opening record, either MODE_READ or MODE_WRITE. May be or'ed with MODE_ALLOC to let db_open_record allocate the memory for the record. |
(*dispatcher) | Function which gets called when record is updated.The argument list composed of: HNDLE hDB, HNDLE hKey, void *info |
info | Additional info passed to the dispatcher. |
Definition at line 13291 of file odb.cxx.
INT EXPRT db_open_record1 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void * | ptr, | ||
INT | rec_size, | ||
WORD | access_mode, | ||
void(*)(INT, INT, void *) | dispatcher, | ||
void * | info, | ||
const char * | rec_str | ||
) |
Open a record. Create a local copy and maintain an automatic update.
This function is same as db_open_record(), except that it calls db_check_record(), db_get_record1() and db_create_record() to ensure that the ODB structure matches
Parameters are the same as for db_open_record():
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
ptr | If access_mode includes MODE_ALLOC: Address of pointer which points to the record data after the call if access_mode includes not MODE_ALLOC: Address of record if ptr==NULL, only the dispatcher is called. |
rec_size | Record size in bytes |
access_mode | Mode for opening record, either MODE_READ or MODE_WRITE. May be or'ed with MODE_ALLOC to let db_open_record allocate the memory for the record. |
(*dispatcher) | Function which gets called when record is updated.The argument list composed of: HNDLE hDB, HNDLE hKey, void *info |
info | Additional info passed to the dispatcher. |
rec_str | ASCII representation of ODB record in the format |
Definition at line 13441 of file odb.cxx.
|
static |
Definition at line 11866 of file odb.cxx.
Copy an ODB subtree in ASCII format from a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
buffer | NULL-terminated buffer |
Definition at line 8487 of file odb.cxx.
Definition at line 687 of file json_paste.cxx.
Definition at line 700 of file json_paste.cxx.
|
static |
Definition at line 8780 of file odb.cxx.
Paste an ODB subtree in XML format from a buffer
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
buffer | NULL-terminated buffer |
Definition at line 8998 of file odb.cxx.
|
static |
Definition at line 113 of file odb.cxx.
Protect a database for read/write access outside of the db_xxx functions
hDB | ODB handle obtained via cm_get_experiment_database(). |
Definition at line 3167 of file odb.cxx.
|
static |
Definition at line 11439 of file odb.cxx.
|
static |
Definition at line 11575 of file odb.cxx.
|
static |
Definition at line 12452 of file odb.cxx.
dox
Definition at line 6261 of file odb.cxx.
Definition at line 6361 of file odb.cxx.
INT EXPRT db_resize_string | ( | HNDLE | hdb, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
int | num_values, | ||
int | max_string_length | ||
) |
Change size of string arrays.
This function can change the number of elements and the string element length of an array of strings.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
key_name | Odb key name, if NULL, will resize ODB entry pointed to by hKey |
num_values | New number of array elements, if 0, remains unchanged |
max_string_length | New max string length for array elements, if 0, remains unchanged |
Definition at line 14025 of file odb.cxx.
|
static |
dox Save a branch of a database to an .ODB file
This function is used by the ODBEdit command save. For a description of the ASCII format, see db_copy(). Data of the whole ODB can be saved (hkey equal zero) or only a sub-tree.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
filename | Filename of .ODB file. |
bRemote | Flag for saving database on remote server. |
Definition at line 9245 of file odb.cxx.
Save a branch of a database to an .json file
This function is used by the ODBEdit command save to write the contents of the ODB into a JSON file. Data of the whole ODB can be saved (hkey equal zero) or only a sub-tree.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
filename | Filename of .json file. |
Definition at line 10527 of file odb.cxx.
|
static |
Definition at line 9811 of file odb.cxx.
INT EXPRT db_save_string | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const char * | file_name, | ||
const char * | string_name, | ||
BOOL | append | ||
) |
dox
Definition at line 10687 of file odb.cxx.
INT EXPRT db_save_struct | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const char * | file_name, | ||
const char * | struct_name, | ||
BOOL | append | ||
) |
Save a branch of a database to a C structure .H file
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
file_name | Filename of .ODB file. |
struct_name | Name of structure. If struct_name == NULL, the name of the key is used. |
append | If TRUE, append to end of existing file |
Definition at line 10626 of file odb.cxx.
Definition at line 9118 of file odb.cxx.
Save a branch of a database to an .xml file
This function is used by the ODBEdit command save to write the contents of the ODB into a XML file. Data of the whole ODB can be saved (hkey equal zero) or only a sub-tree.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
filename | Filename of .XML file. |
Definition at line 9480 of file odb.cxx.
INT db_save_xml_key | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
INT | level, | ||
MXML_WRITER * | writer | ||
) |
Definition at line 9346 of file odb.cxx.
INT EXPRT db_scan_tree | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
INT | level, | ||
INT(*)(HNDLE, HNDLE, KEY *, INT, void *) | callback, | ||
void * | info | ||
) |
INT EXPRT db_scan_tree_link | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
INT | level, | ||
void(*)(HNDLE, HNDLE, KEY *, INT, void *) | callback, | ||
void * | info | ||
) |
|
static |
int db_scan_tree_locked | ( | const DATABASE_HEADER * | pheader, |
const KEY * | pkey, | ||
int | level, | ||
int(*)(const DATABASE_HEADER *pheader, const KEY *, int, void *, db_err_msg **msg) | callback, | ||
void * | info, | ||
db_err_msg ** | msg | ||
) |
Definition at line 4823 of file odb.cxx.
Definition at line 14111 of file odb.cxx.
Send all records to the ODB which were changed locally since the last call to this function.
This function is valid if used in conjunction with db_open_record() under the condition the record is open as MODE_WRITE access code.
Definition at line 13777 of file odb.cxx.
INT EXPRT db_set_data | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | buf_size, | ||
INT | num_values, | ||
DWORD | type | ||
) |
Set key data from a handle. Adjust number of values if previous data has different size.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Buffer from which data gets copied to. |
buf_size | Size of data buffer. |
num_values | Number of data values (for arrays). |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 7215 of file odb.cxx.
INT EXPRT db_set_data1 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | buf_size, | ||
INT | num_values, | ||
DWORD | type | ||
) |
Definition at line 7313 of file odb.cxx.
INT EXPRT db_set_data_index | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type | ||
) |
dox Set key data for a key which contains an array of values.
This function sets individual values of a key containing an array. If the index is larger than the array size, the array is extended and the intermediate values are set to zero.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to single value of data. |
data_size | |
idx | Size of single data element. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 7648 of file odb.cxx.
INT EXPRT db_set_data_index1 | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type, | ||
BOOL | bNotify | ||
) |
dox
Definition at line 7828 of file odb.cxx.
|
static |
Definition at line 7057 of file odb.cxx.
|
static |
Set key data, adjust number of values if previous data has different size.
pkey | Key to change |
idx | Data index to change, "-1" means the whole array of data |
data | Buffer from which data gets copied to. |
data_size | Size of data buffer. |
num_values | Number of data values (for arrays). |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 7014 of file odb.cxx.
INT EXPRT db_set_link_data | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | buf_size, | ||
INT | num_values, | ||
DWORD | type | ||
) |
Same as db_set_data, but it does not follow a link to an array index
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Buffer from which data gets copied to. |
buf_size | Size of data buffer. |
num_values | Number of data values (for arrays). |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 7425 of file odb.cxx.
INT EXPRT db_set_link_data_index | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type | ||
) |
Same as db_set_data_index, but does not follow links.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer to single value of data. |
data_size | |
idx | Size of single data element. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 7754 of file odb.cxx.
Definition at line 2664 of file odb.cxx.
Definition at line 8027 of file odb.cxx.
|
static |
dox
Definition at line 7502 of file odb.cxx.
Copy a set of keys from local memory to the database.
An ODB sub-tree can be mapped to a C structure automatically via a hot-link using the function db_open_record() or manually with this function. Problems might occur if the ODB sub-tree contains values which don't match the C structure. Although the structure size is checked against the sub-tree size, no checking can be done if the type and order of the values in the structure are the same than those in the ODB sub-tree. Therefore it is recommended to use the function db_create_record() before using this function.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key where search starts, zero for root. |
data | Pointer where data is stored. |
buf_size | Size of data structure, must be obtained via sizeof(RECORD-NAME). |
align | Byte alignment calculated by the stub and passed to the rpc side to align data according to local machine. Must be zero when called from user level. |
Definition at line 12291 of file odb.cxx.
INT EXPRT db_set_record2 | ( | HNDLE | hdb, |
HNDLE | hKey, | ||
void * | data, | ||
INT | buf_size, | ||
INT | align, | ||
const char * | rec_str | ||
) |
INT EXPRT db_set_value | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
const void * | data, | ||
INT | data_size, | ||
INT | num_values, | ||
DWORD | type | ||
) |
dox Set value of a single key.
The function sets a single value or a whole array to a ODB key. Since the data buffer is of type void, no type checking can be performed by the compiler. Therefore the type has to be explicitly supplied, which is checked against the type stored in the ODB. key_name can contain the full path of a key (like: "/Equipment/Trigger/Settings/Level1") while hkey is zero which refers to the root, or hkey can refer to a sub-directory (like /Equipment/Trigger) and key_name is interpreted relative to that directory like "Settings/Level1".
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
key_name | Name of key to search, can contain directories. |
data | Address of data. |
data_size | Size of data (in bytes). |
num_values | Number of data elements. |
type | Type of key, one of TID_xxx (see Midas_Data_Types) |
Definition at line 5261 of file odb.cxx.
INT EXPRT db_set_value_index | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type, | ||
BOOL | trunc | ||
) |
Set single value of an array.
The function sets a single value of an ODB key which is an array. key_name can contain the full path of a key (like: "/Equipment/Trigger/Settings/Level1") while hkey is zero which refers to the root, or hkey can refer to a sub-directory (like /Equipment/Trigger) and key_name is interpreted relative to that directory like "Settings/Level1".
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKeyRoot | Handle for key where search starts, zero for root. |
key_name | Name of key to search, can contain directories. |
data | Address of data. |
data_size | Size of data (in bytes). |
index | Array index of value. |
type | Type of key, one of TID_xxx (see Midas_Data_Types) |
truncate | Truncate array to current index if TRUE |
Definition at line 5365 of file odb.cxx.
INT EXPRT db_set_value_string | ( | HNDLE | hDB, |
HNDLE | hKeyRoot, | ||
const char * | key_name, | ||
const std::string * | s | ||
) |
Definition at line 14005 of file odb.cxx.
|
static |
Definition at line 5300 of file odb.cxx.
Definition at line 2976 of file odb.cxx.
Definition at line 670 of file odb.cxx.
Definition at line 14161 of file odb.cxx.
dox Convert a database value to a string according to its type.
This function is a convenient way to convert a binary ODB value into a string depending on its type if is not known at compile time. If it is known, the normal sprintf() function can be used.
string | output ASCII string of data. must be at least MAX_STRING_LENGTH bytes long. |
data | Value data. |
data_size | Size of single data element. |
idx | Index for array data. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 10843 of file odb.cxx.
Convert a database value to a string according to its type.
This function is a convenient way to convert a binary ODB value into a string depending on its type if is not known at compile time. If it is known, the normal sprintf() function can be used.
data | Value data. |
data_size | Size of single data element. |
idx | Index for array data. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 11087 of file odb.cxx.
INT EXPRT db_sprintff | ( | char * | string, |
const char * | format, | ||
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type | ||
) |
Same as db_sprintf, but with additional format parameter
string | output ASCII string of data. |
format | Format specifier passed to sprintf() |
data | Value data. |
data_size | Size of single data element. |
idx | Index for array data. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 10919 of file odb.cxx.
std::string EXPRT db_sprintff | ( | const char * | format, |
const void * | data, | ||
INT | data_size, | ||
INT | idx, | ||
DWORD | type | ||
) |
Same as db_sprintf, but with additional format parameter
string | output ASCII string of data. |
format | Format specifier passed to sprintf() |
data | Value data. |
data_size | Size of single data element. |
idx | Index for array data. |
type | Type of key, one of TID_xxx (see Midas_Data_Types). |
Definition at line 11163 of file odb.cxx.
Definition at line 10983 of file odb.cxx.
dox
Definition at line 11230 of file odb.cxx.
Definition at line 11314 of file odb.cxx.
Unlock a database via system semaphore calls.
hDB | Handle to the database to unlock |
Definition at line 2577 of file odb.cxx.
Remove watch callback from a key previously watched with db_watch.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key, zero for root. |
Definition at line 13887 of file odb.cxx.
Closes all watched variables. This routines is called by db_close_all_databases() and cm_disconnect_experiment()
Definition at line 13917 of file odb.cxx.
Update last activity time
Definition at line 2692 of file odb.cxx.
|
static |
Definition at line 1519 of file odb.cxx.
db_open_record() and db_watch() event handler
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key which changed. |
index | Index for array keys. |
Definition at line 13552 of file odb.cxx.
Relay db_open_record() and db_watch() notification to the remote client.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key which changed. |
index | Index for array keys. |
s | client socket. |
Definition at line 13599 of file odb.cxx.
|
static |
Definition at line 1659 of file odb.cxx.
|
static |
Definition at line 1145 of file odb.cxx.
|
static |
|
static |
|
static |
|
static |
Definition at line 833 of file odb.cxx.
|
static |
Definition at line 1596 of file odb.cxx.
Definition at line 1411 of file odb.cxx.
Watch an ODB subtree. The callback function gets called whenever a key in the watched subtree changes. The callback function receives 4 parameters: the database handle, the key handle of the entry that changed (could be a child if you're watching a directory), the index that changed (if it was part of an array), a user-specified 'info' parameter.
hDB | ODB handle obtained via cm_get_experiment_database(). |
hKey | Handle for key at top of subtree to watch, zero for root. |
(*dispatcher) | Function which gets called when record is updated.The argument list composed of: HNDLE hDB, HNDLE hKey, INT idx, void* info |
Definition at line 13813 of file odb.cxx.
INT EXPRT db_watch | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
void(*)(INT, INT, INT, void *info) | dispatcher, | ||
void * | info | ||
) |
|
static |
Definition at line 448 of file odb.cxx.
|
static |
Definition at line 277 of file odb.cxx.
Definition at line 9627 of file odb.cxx.
void EXPRT json_write | ( | char ** | buffer, |
int * | buffer_size, | ||
int * | buffer_end, | ||
int | level, | ||
const char * | s, | ||
int | quoted | ||
) |
Definition at line 9527 of file odb.cxx.
int EXPRT json_write_anything | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end, | ||
int | level, | ||
int | must_be_subdir, | ||
int | flags, | ||
time_t | timestamp | ||
) |
Definition at line 10384 of file odb.cxx.
|
static |
Definition at line 10250 of file odb.cxx.
int json_write_bare_subdir | ( | HNDLE | hDB, |
HNDLE | hKey, | ||
char ** | buffer, | ||
int * | buffer_size, | ||
int * | buffer_end, | ||
int | level, | ||
int | flags, | ||
time_t | timestamp | ||
) |
Definition at line 10352 of file odb.cxx.
|
static |
Definition at line 9642 of file odb.cxx.
|
static |
|
static |
Definition at line 360 of file odb.cxx.
Definition at line 202 of file odb.cxx.
Definition at line 12659 of file odb.cxx.
|
static |
Definition at line 529 of file odb.cxx.
Definition at line 3235 of file odb.cxx.
|
static |
Definition at line 336 of file odb.cxx.
Definition at line 9303 of file odb.cxx.
|
static |
|
static |
|
static |