arcsinit.cpp
1 /*
2  name: lib/arcsinit.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/arcsinit.h>
30 #include <arcs/arcsfactory.h>
31 
32 ARCSInit ARCSInit::null = ARCSInit();
33 
34 
35 ARCSFactory* ARCSInit::factory = 0;
36 
37 
39 {
40  destination = 0;
41  slotName = QString::null;
42  value = QVariant();
43  constant = false;
44  component = false;
45 }
46 
47 
49 {
50  value = QVariant(i.value);
51  destination = i.destination;
52  slotName = i.slotName;
53  constant = (getValueType() == "constant");
54  component = (getValueType() == "component");
55 }
56 
57 ARCSInit::ARCSInit(ARCSAbstractComponent* d, QString slt, QVariant v)
58 {
59  value = v;
60  destination = d;
61  slotName = slt;
62  constant = (getValueType() == "constant");
63  component = (getValueType() == "component");
64 }
65 
66 
68 {
69 }
70 
71 
73 {
74  if ( destination ==0)
75  return false;
76 
77  destination->init(slotName, &value);
78  return true;
79 }
80 
81 
82 bool ARCSInit::init(QVariant var)
83 {
84  if ( destination ==0)
85  return false;
86 
87  destination->init(slotName, &var);
88  return true;
89 }
90 
92 {
93  if (destination == 0)
94  return false;
95 
96  QVariant var = cmp->getGenuineComponentInstance();
97  destination->init(slotName, &var);
98  return true;
99 }
100 
101 
103 {
104  if (factory == 0)
105  factory = ARCSFactory::getInstance();
106 
107  return factory->getVariantType(value);
108 }
109 
111 {
112  if (factory == 0)
113  factory = ARCSFactory::getInstance();
114 
115  return factory->dataSerialize(value);
116 }
ARCSInit()
Default constructor.
Definition: arcsinit.cpp:38
QString getVariantType(QVariant var)
Returns the type of a QVariant.
bool init(QString slt, QVariant *var)
Initializes a component.
virtual QVariant getGenuineComponentInstance()
Desribes an initialization over a component.
Definition: arcsinit.h:46
QString getValueString()
Definition: arcsinit.cpp:110
static ARCSFactory * getInstance()
Returns the instance of the singleton ARCSFactory.
Class handling the generic description of a component.
A singleton handling all needed factories in ARCS runtime.
Definition: arcsfactory.h:58
~ARCSInit()
Destructor.
Definition: arcsinit.cpp:67
QString getValueType()
Definition: arcsinit.cpp:102
QString dataSerialize(QVariant var)
Serializes data from their QVariant counterpart.
bool init()
Definition: arcsinit.cpp:72