/*
 * Multi-Simulation Interface (MSI)
 * $Id: msi.h,v 1.6 2006/05/18 14:03:00 arubin Exp $
 * Copyright (C) 2002 Lockheed Martin Advanced Technology Labs
 * This is Lockheed Martin PROPRIETARY
 *
 */

#ifndef MSI_H
#define MSI_H

typedef unsigned int MSINodeID;
typedef struct MSIConn MSIConn;
typedef struct MSISubscription MSISubscription;
typedef struct MSIType MSIType;
typedef struct MSINode MSINode;

typedef enum MSIConnType {
  MSI_CONN_FILE = 0,
  MSI_CONN_NETWORK_SOCKET,
  MSI_CONN_LOCAL_SOCKET
} MSIConnType;

typedef enum MSITagType {
  MSI_TAG_NONE = 0,
  MSI_TAG_MSI,
  MSI_TAG_TONE,
  MSI_TAG_PUBLISH,
  MSI_TAG_SUBSCRIBE,
  MSI_TAG_UNSUBSCRIBE,
  MSI_TAG_UPDATE,
  MSI_TAG_MESSAGE
} MSITagType;

struct MSIConn {
  char *name;
  MSIConnType type;
  FILE *file;
  NetAsync *conn;
  double tone;
  int time_unconstrained;
  int waiting;
  MSISubscription *subscriptions;
  DataList *publishings;

  char *pc;
  uint pc_len;
  int do_spool;
  char *spool;
  uint slen;
  MSITagType intag;
  MSINode *updatee;
  char **updated;
  MSIConn *next;
};
#define MSI_CONN(x) ((MSIConn *)(x))

struct MSISubscription {
  MSIConn *conn;
  MSISubscription *cnext;
  MSIType *type;
  MSISubscription *tnext;
  MSINode *node;
  MSISubscription *nnext;
  int children;
  HashTreeNode *attributes;
};
#define MSI_SUBSCRIPTION(x) ((MSISubscription *)(x))

struct MSIType {
  char *name;
  MSISubscription *subscriptions;
  MSINode *members;
};
#define MSI_TYPE(x) ((MSIType *)(x))

struct MSINode {
  long id;
  char *name;
  MSIType *type;
  MSIConn *publisher;
  HashTreeNode *attributes;
  MSISubscription *subscriptions;
  MSINode *parent;
  MSINode *children;
  MSINode *next;
  MSINode *tnext;
};
#define MSI_NODE(x) ((MSINode *)(x))

MSIConn *msi_get_conn( NetAsync *conn, int create );

#endif /* MSI_H */
