main.cpp
1 /*
2  name: tools/libdump/main.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 #include <iostream>
29 #include <arcs/arcsfactory.h>
30 
31 
78 void usage(char* name)
79 {
80  std::cout << "Usage: " << name << " libraries..." << std::endl;
81  std::cout << "This tool is intended to dump library contents. " << std::endl;
82  std::cout << "It is designed to debug complex component libraries using component families" << std::endl;
83 }
84 
85 
86 void dumpLibrary(char* name)
87 {
89  int i,j;
90 
91  std::cout << "Library " << name << std::endl<< "{" << std::endl;
92  factory->loadLibrary(name);
93 
94  QStringList familyList = factory->getFamilyNames();
95  if (familyList.count())
96  {
97  familyList.sort();
98  std::cout << "\tFamilies" << std::endl << "\t{" << std::endl;
99  for(i=0; i<familyList.count(); i++)
100  {
101  if (factory->getFamilyLibrary(familyList[i]) == name
102  && !familyList[i].startsWith(QString(name)+":"))
103  std::cout << "\t\t" << qPrintable(familyList[i]) << ";" << std::endl;
104  }
105  std::cout << "\t}" << std::endl;
106  }
107 
108  QStringList typeList = factory->getTypeNames();
109  if (typeList.count())
110  {
111  typeList.sort();
112  std::cout << "\tTypes" << std::endl << "\t{" << std::endl;
113  for(i=0; i<typeList.count(); i++)
114  {
115  if (factory->getTypeLibrary(typeList[i]) == name
116  && !typeList[i].startsWith(QString(name)+":"))
117  std::cout << "\t\t" << qPrintable(typeList[i]) << ";" << std::endl;
118  }
119  std::cout << "\t}" << std::endl;
120  }
121 
122  QStringList componentList = factory->getLibraryComponents(name);
123  if (componentList.count())
124  {
125  componentList.sort();
126  std::cout << "\tComponents" << std::endl << "\t{" << std::endl;
127 
128  for(i=0; i<componentList.count(); i++)
129  {
130  std::cout << "\t\t" << qPrintable(componentList[i]) << std::endl;
131 
132  ARCSAbstractComponent* aac = factory->createComponent(componentList[i]);
133  std::cout << "\t\t{" << std::endl;
134 
135  QStringList slotList = aac->getSlots();
136  if (slotList.count())
137  {
138  std::cout << "\t\t\tSlots {" << std::endl;
139  for (j=0; j < slotList.count(); j++)
140  std::cout << "\t\t\t\t" << qPrintable(slotList[j]) << ";" << std::endl;
141  std::cout << "\t\t\t}" << std::endl;
142  }
143 
144  QStringList signalList = aac->getSignals();
145  if (signalList.count())
146  {
147  std::cout << "\t\t\tSignals {" << std::endl;
148  for (j=0; j < signalList.count(); j++)
149  std::cout << "\t\t\t\t" << qPrintable(signalList[j]) << ";" << std::endl;
150  std::cout << "\t\t\t}" << std::endl;
151  }
152  factory->destroyComponent(aac);
153  std::cout << "\t\t}" << std::endl;
154  }
155  std::cout << "\t}" << std::endl;
156  }
157 
158  std::cout << "}" << std::endl;
159  factory->unLoadLibrary(name);
160 }
161 
162 
163 
164 
165 
166 int main(int argc, char* argv[])
167 {
168  if (argc <= 1)
169  {
170  usage(argv[0]);
171  return 0;
172  }
173 
174  for (int i=1; i<argc; i++)
175  dumpLibrary(argv[i]);
176 
177  return 0;
178 }
void destroyComponent(ARCSAbstractComponent *aac)
Destroys a component.
QString getTypeLibrary(QString s)
Returns the path of the library associated to a certain kind of type.
virtual QStringList getSlots()=0
Returns the names of the available slots.
static ARCSFactory * getInstance()
Returns the instance of the singleton ARCSFactory.
QStringList getFamilyNames()
Returns the names of the family currently stored.
Definition: arcsfactory.h:83
Class handling the generic description of a component.
A singleton handling all needed factories in ARCS runtime.
Definition: arcsfactory.h:58
void unLoadLibrary(QString path)
Unloads a library given the path to it.
ARCSAbstractComponent * createComponent(QString componentType)
Creates a component given its class name.
QString getFamilyLibrary(QString s)
bool loadLibrary(QString path)
Loads a library given the path to it.
QStringList getLibraryComponents(QString s)
Returns the list of components associated to a library.
QStringList getTypeNames()
Returns the names of the types currently stored.
Definition: arcsfactory.h:79
virtual QStringList getSignals()=0
Returns the names of the availables signals.