arcssensorlogger.h
1 /*
2  name: include/arcs/arcssensorlogger.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 __ARCSSENSORLOGGER_H__
30 #define __ARCSSENSORLOGGER_H__
31 
32 #include <arcs/arcsqdynamicobject.h>
33 #include <QObject>
34 #include <QMutex>
35 #include <QMap>
36 #include <QList>
37 #include <iostream>
38 #include <fstream>
39 
40 
42 
46 class ARCSSensorLoggerBase : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51  ARCSSensorLoggerBase(QObject* parent= 0) : QObject(parent) { }
52  ~ARCSSensorLoggerBase() { if (logFile.is_open() ) logFile.close(); }
53 
54 public slots:
55  void setFilename(QString s);
56 
57 protected:
58  bool canLog();
59  std::ofstream logFile;
60 };
61 
62 
63 
65 
70 {
71 public:
72  ARCSSensorLogger(QObject* parent=0) ;
73  virtual ~ARCSSensorLogger() {}
74 
75  virtual int qt_metacall(QMetaObject::Call call, int id, void ** arguments);
76  virtual QStringList getSignalList() ;
77  virtual QStringList getSlotList() ;
78  virtual int prepareSlotConnect(QString sigName, QString sltName, QString objectName = QString::null, QString actualSignal = QString::null, bool simulate = false) ;
79  virtual int prepareSignalConnect(QString sigName, QString sltName, QString objectName = QString::null, QString actualSlot = QString::null, bool simulate = false);
80  virtual int cleanSlotConnect(QString sigName, QString sltName, QString objectName, QString actualSignal);
81  virtual int cleanSignalConnect(QString sigName, QString sltName, QString objectName, QString actualSlot);
82 
83 private:
84  class LogDetails
85  {
86  public:
87  LogDetails(const LogDetails& ld);
88  LogDetails(QString sn = QString::null, QString obj = QString::null, QString s = QString::null);
89 
90  void addType(QString name, int id) { typeNames << name ; typeIds.append(id); }
91  int count() { return typeNames.count(); }
92 
93  QString getSignature() { return signature; }
94  QString getObject() { return object; }
95  QString getSignal() { return signal; }
96 
97  void getArgument(int i,QString& name, int & id)
98  {
99  if (i < count())
100  {
101  name = typeNames[i];
102  id = typeIds[i];
103  }
104  }
105 
106  private:
107  QString signature;
108  QString object;
109  QString signal;
110  QStringList typeNames;
111  QList<int> typeIds;
112  };
113 
114 
115  QMutex mutex;
116  int idx;
117 
118  QMap<QString, int> map; // this should map a signal to a an integer, which is a slot.
119  QMap<int, LogDetails> invertMap;
120 };
121 
122 #endif // __ARCSSENSORLOGGER_H__
virtual QStringList getSignalList()
virtual int prepareSlotConnect(QString sigName, QString sltName, QString objectName=QString::null, QString actualSignal=QString::null, bool simulate=false)
Prepares a connection with a slot which is belonging to this object.
virtual int qt_metacall(QMetaObject::Call call, int id, void **arguments)
Method performing the actual callback task.
General purpose logging component.
Base class for ARCSSensorLogger.
Interface to extend QObject functionnalities in order to make objects with dynamic signals or slots...
virtual int prepareSignalConnect(QString sigName, QString sltName, QString objectName=QString::null, QString actualSlot=QString::null, bool simulate=false)
Prepares a connection with a slot which does not belong to this object.
virtual QStringList getSlotList()
virtual int cleanSignalConnect(QString sigName, QString sltName, QString objectName, QString actualSlot)
virtual int cleanSlotConnect(QString sigName, QString sltName, QString objectName, QString actualSignal)