2004-01-10 11:20:36 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LAM_INFO_H
|
|
|
|
#define LAM_INFO_H
|
|
|
|
|
2004-02-10 03:09:36 +03:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
#include "mpi.h"
|
2004-02-02 01:27:22 +03:00
|
|
|
#include "lam/lfc/list.h"
|
2004-02-04 01:03:22 +03:00
|
|
|
#include "lam/lam.h"
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-02-02 01:27:22 +03:00
|
|
|
/**
|
|
|
|
* lam_info_t structure. MPI_Info is a pointer to this structure
|
|
|
|
*/
|
2004-01-10 20:10:29 +03:00
|
|
|
struct lam_info_t {
|
2004-02-04 01:03:22 +03:00
|
|
|
lam_list_t super; /**< generic list pointer which is
|
|
|
|
* the container for (key,value) pairs */
|
|
|
|
int i_fhandle; /**< fortran handle for info. This is needed
|
|
|
|
* for translation from fortran to C and vice versa */
|
2004-01-10 20:10:29 +03:00
|
|
|
};
|
|
|
|
typedef struct lam_info_t lam_info_t;
|
2004-01-10 11:20:36 +03:00
|
|
|
|
2004-02-02 01:27:22 +03:00
|
|
|
/**
|
|
|
|
* lam_info_entry_t object. Each item in lam_info_list is of this
|
|
|
|
* type. It contains (key,value) pairs
|
|
|
|
*/
|
|
|
|
struct lam_info_entry_t {
|
|
|
|
lam_list_item_t super; /**< required for lam_list_t type */
|
2004-02-04 01:03:22 +03:00
|
|
|
char *ie_value; /**< value part of the (key, value) pair.
|
2004-02-02 01:27:22 +03:00
|
|
|
* Maximum length is MPI_MAX_INFO_VAL */
|
2004-02-04 01:03:22 +03:00
|
|
|
char ie_key[MPI_MAX_INFO_KEY + 1]; /**< "key" part of the (key, value)
|
2004-02-02 01:27:22 +03:00
|
|
|
* pair */
|
|
|
|
};
|
|
|
|
typedef struct lam_info_entry_t lam_info_entry_t;
|
|
|
|
|
2004-02-04 01:03:22 +03:00
|
|
|
/**
|
|
|
|
* Some declarations needed to use OBJ_CREATE and OBJ_DESTROY macros
|
|
|
|
*/
|
|
|
|
extern lam_class_info_t lam_info_cls;
|
|
|
|
extern lam_class_info_t lam_info_entry_cls;
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void lam_info_init(lam_info_t *info);
|
|
|
|
void lam_info_destroy(lam_info_t *info);
|
|
|
|
|
|
|
|
void lam_info_entry_init(lam_info_entry_t *entry);
|
|
|
|
void lam_info_entry_destroy(lam_info_entry_t *entry);
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate through the list and search for "key"
|
|
|
|
*
|
|
|
|
* @param info MPI_Info handle
|
|
|
|
* @param key Key value to search for
|
|
|
|
*
|
|
|
|
* @retval (lam_info_entry_t *) to the object having the same key
|
|
|
|
* NULL if no matching item is found
|
|
|
|
*
|
|
|
|
* We need a function to go through the entries and find whether
|
|
|
|
* a given key is already present in the list. If so, this function
|
|
|
|
* returns the item which matches this key. It was required
|
|
|
|
* often enough to make it into a function. No error checking on
|
|
|
|
* info is performed.
|
|
|
|
* Assumptions:
|
|
|
|
* "info" is a valid key
|
|
|
|
*/
|
|
|
|
static inline lam_info_entry_t *lam_info_find_key (MPI_Info info,
|
|
|
|
char *key) {
|
|
|
|
lam_info_entry_t *iterator;
|
|
|
|
int nkeys;
|
|
|
|
|
|
|
|
/* Iterate over all the entries. If the key is found, then
|
|
|
|
* return immediately. Else, the loop will fall of the edge
|
|
|
|
* and NULL is returned
|
|
|
|
*/
|
|
|
|
nkeys = lam_list_get_size(&(info->super));
|
|
|
|
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
|
|
|
|
nkeys > 0;
|
|
|
|
nkeys--) {
|
|
|
|
if (0 == strcmp(key, iterator->ie_key)) {
|
|
|
|
return iterator;
|
|
|
|
}
|
|
|
|
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
|
|
|
|
}
|
|
|
|
return (lam_info_entry_t *)0;
|
|
|
|
}
|
|
|
|
|
2004-01-10 11:20:36 +03:00
|
|
|
#endif /* LAM_INFO_H */
|