source: CMT/v1r12p20020606/src/cmt_group.cxx @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 3.7 KB
Line 
1
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <ctype.h>
7
8#include "cmt_group.h"
9#include "cmt_database.h"
10
11/*----------------------------------------------------------*/
12/*                                                          */
13/*  Operations on Groups                                    */
14/*                                                          */
15/*----------------------------------------------------------*/
16
17//----------------------------------------------------------
18Group* Group::find (const cmt_string& name)
19//----------------------------------------------------------
20{
21  static GroupVector& Groups = groups ();
22
23  for (int i = 0; i < Groups.size (); i++)
24    {
25      Group& v = Groups[i];
26
27      if (v.m_name == name) return (&v);
28    }
29
30  return (0);
31}
32
33//----------------------------------------------------------
34Group* Group::add (const cmt_string& name)
35//----------------------------------------------------------
36{
37  static GroupVector& Groups = groups ();
38
39  {
40    Group* group;
41
42    group = find (name);
43    if (group != 0) return (group);
44  }
45
46  Group& group = Groups.add ();
47  group.set (name);
48
49  return (&group);
50}
51
52//----------------------------------------------------------
53Group::GroupVector& Group::groups ()
54//----------------------------------------------------------
55{
56  static Database& db = Database::instance ();
57  static GroupVector& Groups = db.groups ();
58
59  return (Groups);
60}
61
62/*----------------------------------------------------------*/
63void Group::clear_all ()
64/*----------------------------------------------------------*/
65{
66  static GroupVector& Groups = groups ();
67
68  for (int i = 0; i < Groups.size (); i++)
69    {
70      Group& group = Groups[i];
71      group.clear ();
72    }
73
74  Groups.clear ();
75}
76
77/*----------------------------------------------------------*/
78void Group::show_all ()
79/*----------------------------------------------------------*/
80{
81  static GroupVector& Groups = groups ();
82
83  for (int i = 0; i < Groups.size (); i++)
84    {
85      Group& group = Groups[i];
86      cout << group.m_name << endl;
87    }
88}
89
90//----------------------------------------------------------
91Group::Group ()
92//----------------------------------------------------------
93{
94}
95
96//----------------------------------------------------------
97Group::Group (const cmt_string& name) : m_name (name)
98//----------------------------------------------------------
99{
100}
101
102//----------------------------------------------------------
103const cmt_string& Group::name () const
104//----------------------------------------------------------
105{
106  return (m_name);
107}
108
109//----------------------------------------------------------
110void Group::set (const cmt_string& name)
111//----------------------------------------------------------
112{
113  m_name = name;
114}
115
116//----------------------------------------------------------
117void Group::clear ()
118//----------------------------------------------------------
119{
120  m_name = "";
121}
122
123//----------------------------------------------------------
124Group& Group::operator = (const Group& other)
125//----------------------------------------------------------
126{
127  m_name = other.m_name;
128
129  return (*this);
130}
131
132//----------------------------------------------------------
133bool Group::operator == (const cmt_string& name) const
134//----------------------------------------------------------
135{
136  return ((m_name == name));
137}
138
139//----------------------------------------------------------
140bool Group::operator != (const cmt_string& name) const
141//----------------------------------------------------------
142{
143  return ((m_name != name));
144}
145
Note: See TracBrowser for help on using the repository browser.