arcslibmanager.cpp
1 /*
2  name: lib/arcslibmanager.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/arcslibmanager.h>
30 
31 ARCSLibManager::ARCSLibManager(QString libname)
32 {
33  loaded = false ;
34 
35  name = libname;
36 
37  libraryRegister = 0;
38  libraryUnregister = 0;
39 
40  refcount = 0;
41 
42  lib.setFileName(libname);
43  if ( ! lib.load() )
44  return ;
45 
46  libraryRegister = (LibWrapper)lib.resolve("arcsLibraryRegister");
47  if ( !libraryRegister )
48  return ;
49 
50  libraryUnregister = (LibWrapper)lib.resolve("arcsLibraryUnregister");
51  if ( !libraryUnregister )
52  return ;
53 
54  libraryRegister(&components,& families, &types);
55 
56  loaded = true;
57 }
58 
59 
60 ARCSLibManager::~ARCSLibManager()
61 {
62  if (loaded)
63  libraryUnregister(&components, &families, &types);
64 
65  if (lib.isLoaded())
66  lib.unload();
67  loaded = false ;
68  refcount = 0;
69 }