Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

nml.hh

Go to the documentation of this file.
00001 /*************************************************************************
00002 * File: nml.hh                                                           *
00003 * Authors: Fred Proctor, Will Shackleford                                *
00004 * Purpose: C++ Header file for the Neutral Manufacturing Language (NML). *
00005 *          Includes:                                                     *
00006 *               1. class NML.                                            *
00007 *               2. typedef for NMLTYPE.                                  *
00008 *               3. typedef for NML_FORMAT_PTR                            *
00009 *               4. enum NML_ERROR_TYPE                                   *
00010 *************************************************************************/
00011 
00012 #ifndef NML_HH
00013 #define NML_HH
00014 
00015 /* Include Files */
00016 #include "rcs_defs.hh"          /* EXTERN_C_STD_HEADERS */
00017 
00018 
00019 #ifdef EXTERN_C_STD_HEADERS
00020 extern "C"
00021 {
00022 #endif
00023 
00024 #ifndef UNDER_CE
00025 #include <stddef.h>             /* size_t */
00026 #endif
00027 
00028 #ifdef EXTERN_C_STD_HEADERS
00029 }
00030 #endif
00031 
00032 
00033 #include "cms_user.hh"          /* class CMS_USER */
00034 #include "linklist.hh"          /* class RCS_LINKED_LIST */
00035 
00036 /* Generic NML Stuff */
00037 
00038 #ifndef NMLTYPE_TYPEDEFED
00039 #define NMLTYPE_TYPEDEFED
00040 typedef long NMLTYPE;           /* Also defined in nmlmsg.hh */
00041 #endif
00042 
00043 class RCS_EXPORT NMLmsg;        /* Use only partial definition to avoid */
00044                                 /* depending on nmlmsg.hh. */
00045 
00046 /* Typedef for pointer to the function used to decode a message */
00047  /* by its id number. */
00048 typedef int (*NML_FORMAT_PTR) (NMLTYPE, void RCS_FAR *, CMS RCS_FAR *);
00049 
00050 /* Values for NML::error_type. */
00051 enum NML_ERROR_TYPE
00052 {
00053   NML_NO_ERROR,
00054   NML_BUFFER_NOT_READ,
00055   NML_TIMED_OUT,
00056   NML_INVALID_CONFIGURATION,
00057   NML_FORMAT_ERROR,
00058   NML_INTERNAL_CMS_ERROR,
00059   NML_NO_MASTER_ERROR,
00060   NML_INVALID_MESSAGE_ERROR,
00061   NML_QUEUE_FULL_ERROR
00062 };
00063 
00064 
00065 enum NML_CHANNEL_TYPE
00066 {
00067   INVALID_NML_CHANNEL_TYPE = 0,
00068   NML_GENERIC_CHANNEL_TYPE,
00069   RCS_CMD_CHANNEL_TYPE,
00070   RCS_STAT_CHANNEL_TYPE,
00071   NML_QUERY_CHANNEL_TYPE,
00072   NML_ID_CHANNEL_TYPE
00073 };
00074 
00075 
00076 extern char NML_ERROR_TYPE_STRINGS[8][80];
00077 class NML_DIAGNOSTICS_INFO;
00078 
00079 /* nml interface to CMS. */
00080 class RCS_EXPORT NML:public virtual CMS_USER
00081 {
00082 protected:
00083   int run_format_chain (NMLTYPE, void *);
00084   int format_input (NMLmsg * nml_msg);  /* Format message if neccessary */
00085   int format_output ();         /* Decode message if neccessary. */
00086 
00087 public:
00088   void *operator new (size_t);
00089   void operator delete (void *);
00090   RCS_LINKED_LIST *format_chain;
00091   void register_with_server (); /* Add this channel to the server's list. */
00092   void add_to_channel_list ();  /* Add this channel to the main list.  */
00093   int channel_list_id;          /* List id of this channel. */
00094   NML_ERROR_TYPE error_type;    /* check here if an NML function returns -1 */
00095 #ifdef VXWORKS
00096   int pid;
00097 #endif
00098 #ifdef _Windows
00099   // HANDLE replaced with void RCS_FAR *
00100   void RCS_FAR *task_handle;
00101 #endif
00102   /* Get Address of message for user after read. */
00103     NMLTYPE (*phantom_read) ();
00104     NMLTYPE (*phantom_peek) ();
00105   int (*phantom_write) (NMLmsg * nml_msg);
00106   int (*phantom_write_if_read) (NMLmsg * nml_msg);
00107   int (*phantom_check_if_read) ();
00108   int (*phantom_clear) ();
00109   int ignore_format_chain;
00110 
00111   NMLmsg *get_address ();
00112   void delete_channel ();
00113 
00114   /* Read and Write Functions. */
00115   NMLTYPE read ();              /* Read the buffer. */
00116   NMLTYPE blocking_read (double timeout);       /* Read the buffer. (Wait for new data). */
00117   NMLTYPE peek ();              /* Read buffer without changing was_read */
00118   NMLTYPE read (void *, long);
00119   NMLTYPE peek (void *, long);
00120   int write (NMLmsg & nml_msg); /* Write a message. (Use reference) */
00121   int write (NMLmsg * nml_msg); /* Write a message. (Use pointer) */
00122   int write_if_read (NMLmsg & nml_msg); /* Write only if buffer was_read */
00123   int write_if_read (NMLmsg * nml_msg); /*  '' */
00124   NMLTYPE blocking_read_extended (double timeout, double poll_interval);
00125 
00126 
00127   int write_subdivision (int subdiv, NMLmsg & nml_msg); /* Write a message. (Use reference) */
00128   int write_subdivision (int subdiv, NMLmsg * nml_msg); /* Write a message. (Use pointer) */
00129   int write_if_read_subdivision (int subdiv, NMLmsg & nml_msg); /* Write only if buffer was_read */
00130   int write_if_read_subdivision (int subdiv, NMLmsg * nml_msg); /*  '' */
00131   NMLTYPE read_subdivision (int subdiv);        /* Read the buffer. */
00132   NMLTYPE blocking_read_subdivision (int subdiv, double timeout);       /* Read the buffer. (Wait for new data). */
00133   NMLTYPE peek_subdivision (int subdiv);        /* Read buffer without changing was_read */
00134   NMLmsg *get_address_subdivision (int subdiv);
00135   int get_total_subdivisions ();
00136 
00137   void clean_buffers ();
00138   const char *msg2str (NMLmsg & nml_msg);
00139   const char *msg2str (NMLmsg * nml_msg);
00140   NMLTYPE str2msg (const char *);
00141   int login (const char *name, const char *passwd);
00142   void reconnect ();
00143   void disconnect ();
00144 
00145   /* Function to check to see if this NML object is properly configured. */
00146   int valid ();
00147 
00148   /* Make just the check_if_read function from cms available to NML users. */
00149   int check_if_read ();
00150   int check_if_transfers_complete ();
00151 
00152   /* Make just the clear  function from cms available to NML users. */
00153   int clear ();
00154 
00155   /* Get the number of messages written to this buffer so far. */
00156   int get_msg_count ();
00157 
00158   /* Get Diagnostics Information. */
00159   NML_DIAGNOSTICS_INFO *get_diagnostics_info ();
00160 
00161 
00162   int prefix_format_chain (NML_FORMAT_PTR);
00163 
00164   /* Constructors and destructors. */
00165     NML (NML_FORMAT_PTR f_ptr,
00166          char *, char *, char *,
00167          int set_to_server = 0, int set_to_master = 0);
00168     NML (NML *, int set_to_server = 0, int set_to_master = 0);
00169     NML (char *buffer_line, char *proc_line);
00170     virtual ~ NML ();
00171   int reset ();
00172 
00173   int print_queue_info ();
00174   int queue_length;
00175   int set_error ();
00176   void print_info (char *bufname = NULL, char *procname =
00177                    NULL, char *cfg_file = NULL);
00178 protected:
00179   int fast_mode;
00180   int *cms_status;
00181   long *cms_inbuffer_header_size;
00182     NML (char *, char *, char *, int set_to_server = 0, int set_to_master = 0);
00183   void reconstruct (NML_FORMAT_PTR, char *, char *, char *,
00184                     int set_to_server = 0,
00185                     int set_to_master = 0);
00186 
00187   int info_printed;
00188 
00189 
00190 public:
00191     NML_CHANNEL_TYPE channel_type;
00192   long sizeof_message_header;
00193   int forced_type;
00194 
00195 protected:
00196   int already_deleted;
00197   char bufname[40];
00198   char procname[40];
00199   char cfgfilename[160];
00200   double blocking_read_poll_interval;
00201   CMS *cms_for_msg_string_conversions;
00202 
00203     NML (NML & nml);            // Don't copy me.
00204 };
00205 
00206 
00207 int RCS_EXPORT create_NML (NML **, NML_FORMAT_PTR f_ptr,
00208                            char *buf, char *proc, char *file);
00209 
00210 void RCS_EXPORT free_NML (NML *);
00211 
00212 
00213 extern RCS_LINKED_LIST RCS_FAR *NML_Main_Channel_List;
00214 extern "C"
00215 {
00216   extern void RCS_EXPORT nml_start ();
00217   extern void RCS_EXPORT nml_cleanup ();
00218   extern void RCS_EXPORT nml_wipeout_lists ();
00219   extern void RCS_EXPORT set_default_nml_config_file (const char RCS_FAR *);
00220   extern const char *RCS_EXPORT get_default_nml_config_file ();
00221   extern NML *RCS_EXPORT nmlWaitOpen (NML_FORMAT_PTR fPtr, char *buffer,
00222                                       char *name, char *file,
00223                                       double sleepTime);
00224 
00225   extern void nmlSetHostAlias (const char *hostName, const char *hostAlias);
00226   extern void nmlClearHostAliases ();
00227   extern void nmlAllowNormalConnection ();
00228   extern void nmlForceRemoteConnection ();
00229   extern void nmlForceLocalConnection ();
00230 }
00231 
00232 
00233 extern int verbose_nml_error_messages;
00234 extern int nml_print_hostname_on_error;
00235 extern int nml_reset_errors_printed;
00236 
00237 #endif /* !NML_HH */

Generated on Sun Dec 2 15:56:50 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001