GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_selectionset.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #include "glc_selectionset.h"
25 #include "glc_worldhandle.h"
26 
28 : m_pWorldHandle(pWorldHandle)
29 , m_OccurenceHash()
30 {
31  Q_ASSERT(0 == m_pWorldHandle->collection()->selectionSize());
32 
33 }
34 
36 {
37 
38 }
39 
41 // Get Functions
43 
45 {
46  return m_OccurenceHash.isEmpty();
47 }
48 
49 
51 {
52  return m_OccurenceHash.size();
53 }
54 
55 QList<GLC_StructOccurence*> GLC_SelectionSet::occurencesList() const
56 {
57  return m_OccurenceHash.values();
58 }
59 
60 
62 // Set Functions
65 {
66  return insert(pOccurence->id());
67 }
68 
70 {
71  Q_ASSERT(m_pWorldHandle->containsOccurence(occurenceId));
72  if (!m_OccurenceHash.contains(occurenceId))
73  {
74  GLC_StructOccurence* pOccurence= m_pWorldHandle->getOccurence(occurenceId);
75  m_OccurenceHash.insert(occurenceId, pOccurence);
76  return true;
77  }
78  else return false;
79 }
80 
82 {
83  return remove(pOccurence->id());
84 }
85 
87 {
88  Q_ASSERT(m_pWorldHandle->containsOccurence(occurenceId));
89  if (m_OccurenceHash.contains(occurenceId))
90  {
91  m_OccurenceHash.remove(occurenceId);
92  return true;
93  }
94  else return false;
95 }
96 
98 {
99  m_OccurenceHash.clear();
100 }

©2005-2013 Laurent Ribon