arcsinternalfamily.cpp
1 /*
2  name: lib/arcsinternalfamily.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/arcsinternalfamily.h>
30 
31 #include <arcs/arcscompositecomponent.h>
32 #include <arcs/arcscontrollercomponent.h>
33 #include <arcs/arcsapplicationcomponent.h>
34 #include <arcs/arcsscriptcomponent.h>
35 
36 QString ARCSInternalFamily::name() const
37 {
38  return "Internal";
39 }
40 
41 
42 void ARCSInternalFamily::destroy(ARCSAbstractComponent* cmp)
43 {
44  QString type = cmp->getType();
45 
46  if (type == "Composite")
47  {
48  ARCSCompositeComponent* ccmp = dynamic_cast<ARCSCompositeComponent*>(cmp);
49  if (ccmp)
50  delete ccmp;
51  }
52 
53  if (type == "StateMachine")
54  {
55  ARCSControllerComponent* ccmp = dynamic_cast<ARCSControllerComponent*>(cmp);
56  if (ccmp)
57  delete ccmp;
58  }
59 
60  if (type == "Application")
61  {
62  ARCSApplicationComponent* ccmp = dynamic_cast<ARCSApplicationComponent*>(cmp);
63  if (ccmp)
64  delete ccmp;
65  }
66 
67  if (type == "Script" )
68  {
69  ARCSScriptComponent* ccmp = dynamic_cast<ARCSScriptComponent*>(cmp);
70  if (ccmp)
71  delete ccmp;
72  }
73 }
74 
75 
76 ARCSAbstractComponent* ARCSInternalFamily::instanciate(QString type)
77 {
78  if (type == "Composite")
79  return new ARCSCompositeComponent();
80 
81  if (type == "StateMachine")
82  return new ARCSControllerComponent();
83 
84  if (type == "Application")
85  return new ARCSApplicationComponent();
86 
87  if (type == "Script")
88  return new ARCSScriptComponent();
89 
90  return 0;
91 }
92 
93 void ARCSInternalFamily::removeFactory(QString)
94 {
95 }
96 
97 bool ARCSInternalFamily::addFactory(QString, ARCSAbstractComponent* )
98 {
99  return false;
100 }
101 
102 QStringList ARCSInternalFamily::factoryList()
103 {
104  QStringList lst;
105 
106  lst << "Application" << "StateMachine" << "Composite" << "Script" ;
107 
108  return lst;
109 }
Class defining a composite component i.e. a component made of components.
This class represents an application.
Defines a controller component.
Class handling the generic description of a component.
Scripting components.