source: CMT/v1r20b1/source/cmt_group.cxx@ 327

Last change on this file since 327 was 11, checked in by arnault, 21 years ago

Changing eol-style property

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