arcsnativefamily.cpp
1 /*
2  name: lib/arcsnativefamily.cpp
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #include <arcs/arcsfactory.h>
30 #include <QtDebug>
31 
32 QString ARCSNativeFamily::name() const
33 {
34  return QString("native");
35 }
36 
37 
39 {
40  return true;
41 }
42 
43 
44 ARCSNativeFamily::ARCSNativeFamily ()
45 {
46 
47 }
48 
49 
50 ARCSNativeFamily::~ARCSNativeFamily()
51 {
52 
53 }
54 
55 
57 {
58  ARCSNativeComponent* acf = factories.value(type, 0);
59  if (acf == 0)
60  return 0;
61 
62  ARCSNativeComponent* anc = acf->genuineClone();
63  if (anc == 0)
64  return 0;
65 
66  anc->setType(type);
67  anc->setFamily(acf->getFamily());
68  return anc;
69 }
70 
71 
73 {
74  ARCSNativeComponent* acf = dynamic_cast<ARCSNativeComponent*> (whatever);
75 
76  if (acf == 0)
77  return false;
78 
79  if (factories.contains(s))
80  {
81  qCritical() << "[]" ;
82  return false;
83  }
84 
85  factories.insert(s, acf);
86  return true;
87 }
88 
89 
91 {
92  factories.remove(s);
93 }
94 
95 
97 {
98  ARCSNativeComponent* anc = dynamic_cast<ARCSNativeComponent*> (aac);
99 
100  if (anc != 0)
101  delete anc;
102 }
virtual void removeFactory(QString type)
Removes a component factory to the family.
Class handling the generic description of a component.
virtual bool addFactory(QString type, ARCSAbstractComponent *whatever)
Adds a component factory to the family.
virtual bool isInternal() const
Describes wether the family is internal to ARCS or not.
virtual void destroy(ARCSAbstractComponent *component)
Destroys a component.
virtual QString name() const
name of the family
virtual ARCSAbstractComponent * instanciate(QString type)
Returns a component.
virtual ARCSNativeComponent * genuineClone()=0
Kage bunshin no jutsu !
Component representation of ARCS Native components.