LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
ObjectManager.h
Go to the documentation of this file.
1
// Copyright 2002-2013 CEA LIST
2
// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3
//
4
// SPDX-License-Identifier: MIT
5
6
/***************************************************************************
7
* Copyright (C) 2004-2012 by CEA LIST *
8
* *
9
***************************************************************************/
10
11
#ifndef LIMA_COMMON_ABSTRACTFACTORYPATTERN_OBJECTMANAGER_H
12
#define LIMA_COMMON_ABSTRACTFACTORYPATTERN_OBJECTMANAGER_H
13
14
#include "
MainFactory.h
"
15
#include "
common/AbstractFactoryPattern/AbstractFactoryPatternExport.h
"
16
#include "
common/XMLConfigurationFiles/moduleConfigurationStructure.h
"
17
#include "
common/XMLConfigurationFiles/xmlConfigurationFileExceptions.h
"
18
19
namespace
Lima
20
{
21
28
template
<
typename
Object>
29
class
ObjectManager
30
{
31
public
:
32
36
virtual
~ObjectManager
();
37
45
virtual
std::shared_ptr<Object>
getObject
(
const
std::string&
id
);
46
47
protected
:
48
55
virtual
std::shared_ptr<Object>
createObject
(
const
std::string&
id
) = 0;
56
57
private
:
58
59
typedef
typename
std::map<std::string, std::shared_ptr<Object>> ObjectMap;
60
typedef
typename
std::map<std::string, std::shared_ptr<Object>>::iterator ObjectMapItr;
61
ObjectMap m_objects;
62
};
63
64
template
<
typename
Object>
65
ObjectManager<Object>::~ObjectManager
()
66
{
67
// for (ObjectMapItr it=m_objects.begin();
68
// it!=m_objects.end();
69
// it++)
70
// {
71
// delete it->second;
72
// it->second=0;
73
// }
74
m_objects.clear();
75
}
76
77
template
<
typename
Object>
78
std::shared_ptr<Object>
ObjectManager<Object>::getObject
(
79
const
std::string&
id
) {
80
auto
ioItr = m_objects.find(
id
);
81
if
(ioItr == m_objects.end())
82
{
83
auto
obj = this->createObject(
id
);
84
m_objects[id] = obj;
85
return
obj;
86
}
87
return
ioItr->second;
88
}
89
90
}
// Lima
91
92
#endif
AbstractFactoryPatternExport.h
MainFactory.h
Defines the MainFactory to create Object.
Lima::ObjectManager
Manager for objects.
Definition
ObjectManager.h:30
Lima::ObjectManager::createObject
virtual std::shared_ptr< Object > createObject(const std::string &id)=0
create the required object.
Lima::ObjectManager::getObject
virtual std::shared_ptr< Object > getObject(const std::string &id)
If object doesn't exists, call the create method.
Definition
ObjectManager.h:78
Lima::ObjectManager::~ObjectManager
virtual ~ObjectManager()
ObjectManager destructor.
Definition
ObjectManager.h:65
moduleConfigurationStructure.h
originally detectModuleConfigurationStructure.h in detectlibraries
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
xmlConfigurationFileExceptions.h
launch exception related to the configuration file parsing
lima_common
src
common
AbstractFactoryPattern
ObjectManager.h
Generated by
1.9.8