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

NML_INTERP_LIST Class Reference

#include <interpl.hh>

Collaboration diagram for NML_INTERP_LIST:

Collaboration graph
[legend]

Public Methods

 NML_INTERP_LIST ()
 ~NML_INTERP_LIST ()
int set_line_number (int line)
int get_line_number ()
int append (NMLmsg &)
int append (NMLmsg *)
NMLmsg * get ()
void clear ()
void print ()
int len ()

Private Attributes

RCS_LINKED_LIST * linked_list_ptr
NML_INTERP_LIST_NODE temp_node
int next_line_number
int line_number

Constructor & Destructor Documentation

NML_INTERP_LIST::NML_INTERP_LIST  
 

Definition at line 31 of file interpl.cc.

00032 {
00033   linked_list_ptr = new RCS_LINKED_LIST;
00034 
00035   next_line_number = 0;
00036   line_number = 0;
00037 }

NML_INTERP_LIST::~NML_INTERP_LIST  
 

Definition at line 39 of file interpl.cc.

00040 {
00041   if (NULL != linked_list_ptr)
00042   {
00043     delete linked_list_ptr;
00044     linked_list_ptr = NULL;
00045   }
00046 }


Member Function Documentation

int NML_INTERP_LIST::append NMLmsg *    nml_msg_ptr
 

Definition at line 108 of file interpl.cc.

00109 {
00110   /* check for invalid data */
00111   if (NULL == nml_msg_ptr)
00112   {
00113     rcs_print_error("NML_INTERP_LIST::append : attempt to append NULL msg\n");
00114     return -1;
00115   }
00116 
00117   if (0 == nml_msg_ptr->type)
00118   {
00119     rcs_print_error("NML_INTERP_LIST::append : attempt to append 0 type\n");
00120     return -1;
00121   }
00122 
00123   if(nml_msg_ptr->size > MAX_NML_COMMAND_SIZE -64 )
00124     {
00125       rcs_print_error("NML_INTERP_LIST::append : command size is too large.");
00126       return -1;
00127     }
00128   if(nml_msg_ptr->size < 4 ) 
00129     {
00130       rcs_print_error("NML_INTERP_LIST::append : command size is invalid.");
00131       return -1;
00132     }
00133 #ifdef DEBUG_INTERPL
00134   if(sizeof(temp_node) < MAX_NML_COMMAND_SIZE+4 ||
00135      sizeof(temp_node) > MAX_NML_COMMAND_SIZE+16 ||
00136      ((void *) &temp_node.line_number) > ((void *) &temp_node.command.commandbuf))
00137     {
00138       rcs_print_error("NML_INTERP_LIST::append : assumptions about NML_INTERP_LIST_NODE have been violated.");
00139       return -1;
00140     }
00141 #endif
00142 
00143   if (NULL == linked_list_ptr)
00144   {
00145     return -1;
00146   }
00147 
00148   // fill in the NML_INTERP_LIST_NODE
00149   temp_node.line_number = next_line_number;
00150   memcpy(temp_node.command.commandbuf, nml_msg_ptr, nml_msg_ptr->size);
00151 
00152   // stick it on the list
00153   linked_list_ptr->store_at_tail(&temp_node, nml_msg_ptr->size+sizeof(temp_node.line_number)+sizeof(temp_node.dummy)+32+(32-nml_msg_ptr->size%32), 1);
00154 
00155 #ifdef DEBUG_INTERPL
00156   if(EMC_DEBUG & EMC_DEBUG_INTERP_LIST)
00157     {
00158       rcs_print("NML_INTERP_LIST::append(nml_msg{size=%d,type=%d}) : list_size=%d, line_number = %d\n",
00159                 nml_msg_ptr->size,nml_msg_ptr->type,linked_list_ptr->list_size,
00160                 temp_node.line_number);
00161     }
00162 #endif
00163 
00164   return 0;
00165 }

int NML_INTERP_LIST::append NMLmsg &    nml_msg
 

Definition at line 48 of file interpl.cc.

00049 {
00050   /* check for invalid data */
00051   if (0 == nml_msg.type)
00052   {
00053     rcs_print_error("NML_INTERP_LIST::append : attempt to append 0 type\n");
00054     return -1;
00055   }
00056 
00057   if (NULL == linked_list_ptr)
00058   {
00059     return -1;
00060   }
00061 
00062   if(nml_msg.size > MAX_NML_COMMAND_SIZE -64)
00063     {
00064       rcs_print_error("NML_INTERP_LIST::append : command size is too large.");
00065       return -1;
00066     }
00067   if(nml_msg.size < 4 ) 
00068     {
00069       rcs_print_error("NML_INTERP_LIST::append : command size is invalid.");
00070       return -1;
00071     }
00072 #ifdef DEBUG_INTERPL
00073   if(sizeof(temp_node) < MAX_NML_COMMAND_SIZE+4 ||
00074      sizeof(temp_node) > MAX_NML_COMMAND_SIZE+16   )
00075     {
00076       rcs_print_error("NML_INTERP_LIST::append : assumptions about NML_INTERP_LIST_NODE have been violated.\n");
00077       return -1;
00078     }
00079 #endif
00080 
00081   // fill in the NML_INTERP_LIST_NODE
00082   temp_node.line_number = next_line_number;
00083   memcpy(temp_node.command.commandbuf, &nml_msg, nml_msg.size);
00084 
00085   // stick it on the list
00086   linked_list_ptr->store_at_tail(&temp_node, nml_msg.size+sizeof(temp_node.line_number)+sizeof(temp_node.dummy)+32+(32-nml_msg.size%32), 1);
00087 
00088 #ifdef DEBUG_INTERPL
00089   if(EMC_DEBUG & EMC_DEBUG_INTERP_LIST)
00090     {
00091       rcs_print("NML_INTERP_LIST::append(nml_msg{size=%d,type=%d}) : list_size=%d, line_number = %d\n",
00092                 nml_msg.size,nml_msg.type,linked_list_ptr->list_size,
00093                 temp_node.line_number);
00094     }
00095 #endif
00096 
00097   return 0;
00098 }

void NML_INTERP_LIST::clear  
 

Definition at line 195 of file interpl.cc.

00196 {
00197   if (NULL != linked_list_ptr)
00198   {
00199     linked_list_ptr->delete_members();
00200   }
00201 }

NMLmsg * NML_INTERP_LIST::get  
 

Definition at line 167 of file interpl.cc.

Referenced by checkInterpList().

00168 {
00169   NMLmsg *ret;
00170   NML_INTERP_LIST_NODE *node_ptr;
00171 
00172   if (NULL == linked_list_ptr)
00173   {
00174     line_number = 0;
00175     return NULL;
00176   }
00177 
00178   node_ptr = (NML_INTERP_LIST_NODE *) linked_list_ptr->retrieve_head();
00179 
00180   if (NULL == node_ptr)
00181   {
00182     line_number = 0;
00183     return NULL;
00184   }
00185 
00186   // save line number of this one, for use by get_line_number
00187   line_number = node_ptr->line_number;
00188 
00189   // get it off the front
00190   ret = (NMLmsg *) ((char *) node_ptr->command.commandbuf);
00191 
00192   return ret;
00193 }

int NML_INTERP_LIST::get_line_number  
 

Definition at line 233 of file interpl.cc.

00234 {
00235   return line_number;
00236 }

int NML_INTERP_LIST::len  
 

Definition at line 223 of file interpl.cc.

Referenced by checkInterpList().

00224 {
00225   if (NULL == linked_list_ptr)
00226   {
00227     return 0;
00228   }
00229 
00230   return ((int) linked_list_ptr->list_size);
00231 }

void NML_INTERP_LIST::print  
 

Definition at line 203 of file interpl.cc.

00204 {
00205   NMLmsg *nml_msg;
00206 
00207   if (NULL == linked_list_ptr)
00208   {
00209     return;
00210   }
00211 
00212   nml_msg = (NMLmsg *) linked_list_ptr->get_head();
00213 
00214   while (NULL != nml_msg)
00215   {
00216     rcs_print("%d ", nml_msg->type);
00217     nml_msg = (NMLmsg *)linked_list_ptr->get_next();
00218   }
00219 
00220   rcs_print("\n");
00221 }

int NML_INTERP_LIST::set_line_number int    line
 

Definition at line 101 of file interpl.cc.

00102 {
00103   next_line_number = line;
00104 
00105   return 0;
00106 }


Field Documentation

int NML_INTERP_LIST::line_number [private]
 

Definition at line 68 of file interpl.hh.

RCS_LINKED_LIST* NML_INTERP_LIST::linked_list_ptr [private]
 

Definition at line 65 of file interpl.hh.

int NML_INTERP_LIST::next_line_number [private]
 

Definition at line 67 of file interpl.hh.

NML_INTERP_LIST_NODE NML_INTERP_LIST::temp_node [private]
 

Definition at line 66 of file interpl.hh.


The documentation for this class was generated from the following files:
Generated on Sun Dec 2 15:29:11 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001