/* oms_pr.h: 					*/
/* Opnet Model Support package	*/
/* Process Registry sub-package	*/

/****************************************/
/*  Copyright (c) 1987 - 1996			*/
/*            by MIL 3, Inc.           	*/
/*       (A Delaware Corporation)      	*/
/*    3400 International Drive, N.W.   	*/
/*       Washington, D.C., U.S.A.      	*/
/*       All Rights Reserved.          	*/
/****************************************/


/* ---- (SECTION_SC) SYMBOLIC CONSTANTS ---- */

typedef enum 
	{
	OMSC_PR_OBJID,
	OMSC_PR_STRING,
	OMSC_PR_NUMBER,
	OMSC_PR_STRINGLIST,
	OMSC_PR_PROHANDLE,
	OMSC_PR_ADDRESS,
	OMSC_PR_INVALID
	} OmsC_Attr_Type; 


#define OMSC_PR_EMPTY_PROCESS_REG 	{OPC_NIL}
#define OMSC_PR_EMPTY_INDEX 		{OPC_NIL}


/* ---- (SECTION_DT) DATA TYPES ---- */

typedef struct
	{
	Prohandle			opnet_pro_handle;
	List*				attr_list_ptr;
	} OmsT_Pr_Process_Record;


typedef OmsT_Pr_Process_Record* 	OmsT_Pr_Handle;

/* (3366) Index: consists of a list of attribute groups.*/
/* used to accelerate query which obtains process		*/
/* record discovery given attributes and their values.	*/

typedef struct
	{
	List*					attr_group_list_ptr;
	int						valid;
	} OmsT_Pr_Index;


typedef struct
	{
	List*					process_list_ptr;
	OmsT_Pr_Index			index;
	} OmsT_Pr_Process_Registry;


typedef union
	{
	Objid					objid;
	char*					string;
	double					number;
	List*					string_list_ptr;
	Prohandle				pro_handle;
	void*					address;
	} OmsT_Pr_Attr_Value;


typedef struct
	{
	char*					name;
	OmsC_Attr_Type			type;	
	OmsT_Pr_Attr_Value		value;
	} OmsT_Pr_Attr;


/* Attribtue Group: list of attributes with the same name. 	*/
/* Within the attribute group, many different attrs. with	*/
/* different types and values can be maintained. 			*/
typedef struct
	{
	char*					attr_name;
	List*					attr_list_ptr;
	} OmsT_Pr_Index_Attr_Group;

/* Index Attribute: Reference to an attribute and the 		*/
/* process record to which the attr. belongs. Once found, 	*/
/* this structure allows a query to return the process rec.	*/
typedef struct
	{
	OmsT_Pr_Attr			*attr_ptr;
	OmsT_Pr_Process_Record	*pr_rec_ptr;
	} OmsT_Pr_Index_Attr;




/* ---- (SECTION_FP) FUNCTION PROTOTYPES ---- */

extern OmsT_Pr_Handle
oms_pr_process_register (Objid node_objid, Objid module_objid, Prohandle op_pro_handle, char* process_name);

extern Compcode
oms_pr_process_discover (Objid neighbor_objid, List* pr_handle_list_ptr, char* attr0_name, ...);

extern Compcode
oms_pr_attr_set (OmsT_Pr_Handle pr_handle, ...);

extern Compcode
oms_pr_attr_get (OmsT_Pr_Handle pr_handle, char* attr_name, OmsC_Attr_Type attr_type, ...);

static void
oms_pr_process_record_add (OmsT_Pr_Process_Registry* reg_ptr, OmsT_Pr_Process_Record* rec_ptr);

static OmsT_Pr_Attr*
oms_pr_attr_find (List* attr_list_ptr, char* attr_name, OmsC_Attr_Type attr_type);

static OmsT_Pr_Handle
oms_pr_process_handle_generate (OmsT_Pr_Process_Record* rec_ptr);

static OmsT_Pr_Attr*
oms_pr_process_attr_create ();

static OmsT_Pr_Process_Record*
oms_pr_process_record_create ();

static void
oms_pr_registry_init (OmsT_Pr_Process_Registry* reg_ptr);



