arcsproxycomponent.h
1 /*
2  name: include/arcs/arcsproxycomponent.h
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 #ifndef __ARCSPROXYCOMPONENT_H__
30 #define __ARCSPROXYCOMPONENT_H__
31 
32 #include <arcs/arcsabstractcomponent.h>
33 #include <arcs/arcscontext.h>
34 
36 
43 {
44 public:
45  ARCSProxyComponent() : ARCSAbstractComponent(), realOne(0), context(0), name() {}
47 
48  void setContext(ARCSContext* ctx) { context = ctx; }
49  ARCSContext* getContext() { return context; }
50 
51  virtual QString toString() { return name; }
52  virtual bool parseString(QString s)
53  {
54  if (context)
55  realOne = context->getComponent(s);
56  if (realOne)
57  {
58  name = s;
59  return true;
60  }
61  return false;
62  }
63  virtual QStringList getSignals()
64  {
65  if (realOne)
66  return realOne->getSignals();
67  else
68  return QStringList();
69  }
70  virtual QStringList getSlots()
71  {
72  if (realOne)
73  return realOne->getSlots();
74  else
75  return QStringList();
76  }
77 
78 protected:
79  virtual void getProxySlot (QString slot, ObjectList &obj, QStringList &proxySlot)
80  { if (realOne) realOne->getProxySlot(slot, obj, proxySlot); }
81  virtual void getProxySignal (QString signal, ObjectList &obj, QStringList &proxySignal)
82  { if (realOne) realOne->getProxySignal(signal, obj, proxySignal); }
83  virtual bool genuineConnect (QString sig, ARCSAbstractComponent *dst, QString slt, bool queued=false)
84  {
85  if (realOne)
86  return realOne->genuineConnect(sig, dst, slt, queued);
87  else
88  return false;
89  }
90  virtual bool genuineDisconnect (QString sig, ARCSAbstractComponent *dst, QString slt)
91  {
92  if (realOne)
93  return realOne->genuineDisconnect(sig, dst, slt);
94  else
95  return false;
96  }
97  virtual bool genuineInstanciate ()
98  {
99  if (realOne)
100  realOne->genuineInstanciate();
101  else
102  return false;
103  }
104  virtual void genuineDestroy ()
105  { if (realOne) realOne->genuineDestroy(); }
106 
107 
108 private:
109  ARCSAbstractComponent* realOne;
110  ARCSContext* context;
111  QString name;
112 
113 };
114 
115 #endif // __ARCSPROXYCOMPONENT_H__
virtual bool genuineInstanciate()
This method should implement the instanciation of the actual component.
virtual void getProxySignal(QString signal, ObjectList &obj, QStringList &proxySignal)=0
Creates a proxy signal to interface a component to native ARCS components.
virtual void getProxySlot(QString slot, ObjectList &obj, QStringList &proxySlot)
Creates a proxy slot to interface a component to native ARCS components.
virtual bool genuineDisconnect(QString, ARCSAbstractComponent *, QString)
This method disconnects two components by the indicated signals and slots.
virtual void getProxySlot(QString slot, ObjectList &obj, QStringList &proxySlot)=0
Creates a proxy slot to interface a component to native ARCS components.
virtual void genuineDestroy()
This method should implement the destruction of the actual component.
virtual QStringList getSlots()=0
Returns the names of the available slots.
Class handling the generic description of a component.
virtual bool parseString(QString s)
Defines a basic seralization mechanism.
virtual bool genuineDisconnect(QString sig, ARCSAbstractComponent *dst, QString slt)
This method disconnects two components by the indicated signals and slots.
virtual bool genuineConnect(QString sig, ARCSAbstractComponent *dst, QString slt, bool queued=false)
This method connects two components by the indicated signals and slots.
ARCSAbstractComponent * getComponent(QString name)
Retrieves a component by its id.
virtual QString toString()
Defines a basic seralization mechanism.
Component linking.
virtual QStringList getSignals()
Returns the names of the availables signals.
This class manages components and constants in a given context.
Definition: arcscontext.h:45
virtual void genuineDestroy()=0
This method should implement the destruction of the actual component.
virtual bool genuineInstanciate()=0
This method should implement the instanciation of the actual component.
virtual QStringList getSlots()
Returns the names of the available slots.
virtual void getProxySignal(QString signal, ObjectList &obj, QStringList &proxySignal)
Creates a proxy signal to interface a component to native ARCS components.
virtual bool genuineConnect(QString, ARCSAbstractComponent *, QString, bool=false)
This method connects two components by the indicated signals and slots.
virtual QStringList getSignals()=0
Returns the names of the availables signals.