Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cmt_group.cxx

Go to the documentation of this file.
00001 
00002 
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <ctype.h>
00007 
00008 #include "cmt_group.h"
00009 #include "cmt_database.h"
00010 
00011 /*----------------------------------------------------------*/
00012 /*                                                          */
00013 /*  Operations on Groups                                    */
00014 /*                                                          */
00015 /*----------------------------------------------------------*/
00016 
00017 //----------------------------------------------------------
00018 Group* Group::find (const cmt_string& name)
00019 //----------------------------------------------------------
00020 {
00021   static GroupVector& Groups = groups ();
00022 
00023   for (int i = 0; i < Groups.size (); i++)
00024     {
00025       Group& v = Groups[i];
00026 
00027       if (v.m_name == name) return (&v);
00028     }
00029 
00030   return (0);
00031 }
00032 
00033 //----------------------------------------------------------
00034 Group* Group::add (const cmt_string& name)
00035 //----------------------------------------------------------
00036 {
00037   static GroupVector& Groups = groups ();
00038 
00039   {
00040     Group* group;
00041 
00042     group = find (name);
00043     if (group != 0) return (group);
00044   }
00045 
00046   Group& group = Groups.add ();
00047   group.set (name);
00048 
00049   return (&group);
00050 }
00051 
00052 //----------------------------------------------------------
00053 Group::GroupVector& Group::groups ()
00054 //----------------------------------------------------------
00055 {
00056   static Database& db = Database::instance ();
00057   static GroupVector& Groups = db.groups ();
00058 
00059   return (Groups);
00060 }
00061 
00062 /*----------------------------------------------------------*/
00063 void Group::clear_all ()
00064 /*----------------------------------------------------------*/
00065 {
00066   static GroupVector& Groups = groups ();
00067 
00068   for (int i = 0; i < Groups.size (); i++)
00069     {
00070       Group& group = Groups[i];
00071       group.clear ();
00072     }
00073 
00074   Groups.clear ();
00075 }
00076 
00077 /*----------------------------------------------------------*/
00078 void Group::show_all ()
00079 /*----------------------------------------------------------*/
00080 {
00081   static GroupVector& Groups = groups ();
00082 
00083   for (int i = 0; i < Groups.size (); i++)
00084     {
00085       Group& group = Groups[i];
00086       cout << group.m_name << endl;
00087     }
00088 }
00089 
00090 //----------------------------------------------------------
00091 Group::Group ()
00092 //----------------------------------------------------------
00093 {
00094 }
00095 
00096 //----------------------------------------------------------
00097 Group::Group (const cmt_string& name) : m_name (name)
00098 //----------------------------------------------------------
00099 {
00100 }
00101 
00102 //----------------------------------------------------------
00103 const cmt_string& Group::name () const
00104 //----------------------------------------------------------
00105 {
00106   return (m_name);
00107 }
00108 
00109 //----------------------------------------------------------
00110 void Group::set (const cmt_string& name)
00111 //----------------------------------------------------------
00112 {
00113   m_name = name;
00114 }
00115 
00116 //----------------------------------------------------------
00117 void Group::clear ()
00118 //----------------------------------------------------------
00119 {
00120   m_name = "";
00121 }
00122 
00123 //----------------------------------------------------------
00124 Group& Group::operator = (const Group& other)
00125 //----------------------------------------------------------
00126 {
00127   m_name = other.m_name;
00128 
00129   return (*this);
00130 }
00131 
00132 //----------------------------------------------------------
00133 bool Group::operator == (const cmt_string& name) const
00134 //----------------------------------------------------------
00135 {
00136   return ((m_name == name));
00137 }
00138 
00139 //----------------------------------------------------------
00140 bool Group::operator != (const cmt_string& name) const
00141 //----------------------------------------------------------
00142 {
00143   return ((m_name != name));
00144 }
00145 

Generated at Thu Apr 11 16:49:41 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000