Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

rmq.C

Go to the documentation of this file.
00001 
00009 
00010 //   version 1:  Jan 1993   Piet Hut
00011 
00012 #include "node.h"
00013 
00014 #ifdef TOOLBOX
00015 
00016 /*-----------------------------------------------------------------------------
00017  *  rm_all_dyn_q  --  only flat tree so far
00018  *-----------------------------------------------------------------------------
00019  */
00020 void  rm_all_dyn_q(node * n, char * qname)
00021     {
00022     node * ni;
00023 
00024     for (ni=n->get_oldest_daughter(); ni != NULL; ni=ni->get_younger_sister())
00025         rmq(ni->get_dyn_story(), qname);
00026     }
00027 
00028 /*-----------------------------------------------------------------------------
00029  *  rm_all_hydro_q  --  only flat tree so far
00030  *-----------------------------------------------------------------------------
00031  */
00032 void  rm_all_hydro_q(node * n, char * qname)
00033     {
00034     node * ni;
00035 
00036     for (ni=n->get_oldest_daughter(); ni != NULL; ni=ni->get_younger_sister())
00037         rmq(ni->get_hydro_story(), qname);
00038     }
00039 
00040 /*-----------------------------------------------------------------------------
00041  *  rm_all_star_q  --  only flat tree so far
00042  *-----------------------------------------------------------------------------
00043  */
00044 void  rm_all_star_q(node * n, char * qname)
00045     {
00046     node * ni;
00047 
00048     for (ni=n->get_oldest_daughter(); ni != NULL; ni=ni->get_younger_sister())
00049         rmq(ni->get_star_story(), qname);
00050     }
00051 
00052 /* endof: rmq.c */
00053 
00054 /*-----------------------------------------------------------------------------
00055  *  main  --  removes a quantity with the name `name' from a dyn (or star or
00056  *            hydro) story, when invoked as  "rmq -q name".
00057  *     default: "rmq -q name" removes quantity from dyn story
00058  *   -h option: "rmq -h -q name" removes quantity from hydro story
00059  *   -s option: "rmq -s -q name" removes quantity from hydro story
00060  *-----------------------------------------------------------------------------
00061  */
00062 main(int argc, char ** argv)
00063     {
00064     bool  h_flag = FALSE;
00065     bool  s_flag = FALSE;
00066     bool  q_flag = FALSE;
00067     bool  c_flag = FALSE;
00068     char  *comment;
00069     char  *qname;
00070 
00071     check_help();
00072 
00073     extern char *poptarg;
00074     int c;
00075     char* param_string = "c:q:hs";
00076 
00077     while ((c = pgetopt(argc, argv, param_string)) != -1)
00078         switch(c)
00079             {
00080             case 'c': c_flag = TRUE;
00081                       comment = poptarg;
00082                       break;
00083             case 'q': q_flag = TRUE;
00084                       qname = poptarg;
00085                       break;
00086             case 'h': h_flag = TRUE;
00087                       break;
00088             case 's': s_flag = TRUE;
00089                       break;
00090             case '?': params_to_usage(cerr, argv[0], param_string);
00091                       get_help();
00092                       exit(1);
00093             }            
00094     
00095     if (q_flag == FALSE)
00096         get_help();
00097 
00098     node *n;
00099 
00100     while (n = get_node(cin))
00101         {
00102         if (c_flag)
00103             n->log_comment(comment);
00104         n->log_history(argc, argv);
00105 
00106         if (h_flag)
00107             rm_all_hydro_q(n, qname);
00108         else if (s_flag)
00109             rm_all_star_q(n, qname);
00110         else
00111             rm_all_dyn_q(n, qname);
00112 
00113         put_node(cout, *n);     
00114         delete n;
00115         }
00116     }
00117 
00118 #endif

Generated at Sun Feb 24 09:57:13 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001