FactoryCollectionBase.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package
19* @author Mirko Waechter( waechter at kit dot edu)
20* @date 2013
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
26
27#include <mutex>
28
29namespace armarx
30{
34
35 std::mutex&
37 {
38 static std::mutex mutex;
39 return mutex;
40 }
41
42 FactoryCollectionBaseCleanUp
44 {
45 std::unique_lock lock(FactoryCollectionBase_RegistrationListMutex());
46
47 //ARMARX_IMPORTANT_S << VAROUT(factoryCollection->getFactories());
48
49 PreregistrationList().push_back(factoryCollection);
50
51 /*for(const FactoryCollectionBasePtr& fc : PreregistrationList())
52 {
53 ARMARX_IMPORTANT_S << VAROUT(fc->getFactories());
54 }*/
55
56 return FactoryCollectionBaseCleanUp(factoryCollection);
57 }
58
59 std::vector<FactoryCollectionBasePtr>&
61 {
62
63 // std::unique_lock lock(registrationListMutex());
64 static std::vector<FactoryCollectionBasePtr> list;
65 return list;
66 }
67
68 FactoryCollectionBaseCleanUp::FactoryCollectionBaseCleanUp(
69 FactoryCollectionBasePtr factoryToRemoveOnDesctruction)
70 {
71 factoryCollection = factoryToRemoveOnDesctruction;
72 //ARMARX_INFO << "ctor FactoryCollectionBaseCleanUp " << factoryToRemoveOnDesctruction->getFactories();
73 }
74
76 {
77 std::unique_lock lock(FactoryCollectionBase_RegistrationListMutex());
78
79 //ARMARX_INFO << "Destruct FactoryCollectionBaseCleanUp";
80
81 // std::cout << "FactoryCollectionBaseCleanUp" << std::endl;
82 for (unsigned int i = 0; i < FactoryCollectionBase::PreregistrationList().size(); i++)
83 {
84 if (FactoryCollectionBase::PreregistrationList().at(i).get() == factoryCollection.get())
85 {
86 //ARMARX_INFO << "erasing: " <<factoryCollection->getFactories().begin()->first << " and co." << std::endl;
87 // std::cout << "erasing: " <<factoryCollection->getFactories().begin()->first << " and co." << std::endl;
90 }
91 }
92 }
93} // namespace armarx
static std::vector< FactoryCollectionBasePtr > & PreregistrationList()
static FactoryCollectionBaseCleanUp addToPreregistration(FactoryCollectionBasePtr factoryCollection)
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::mutex & FactoryCollectionBase_RegistrationListMutex()
IceUtil::Handle< FactoryCollectionBase > FactoryCollectionBasePtr