LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
constraintFunctionManager.cpp
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
*
8
* @file constraintFunctionManager.cpp
9
* @author besancon (besanconr@zoe.cea.fr)
10
* @date Wed Mar 16 2005
11
* @version $Id$
12
* copyright Copyright (C) 2005-2012 by CEA LIST
13
*
14
***********************************************************************/
15
16
#include "
constraintFunctionManager.h
"
17
#include "
constraintFunctionFactory.h
"
18
#include "
constraintFunction.h
"
19
#include "boost/tuple/tuple.hpp"
// for tie
20
21
namespace
Lima
{
22
namespace
LinguisticProcessing
{
23
namespace
Automaton
{
24
25
ConstraintFunctionManager::ConstraintFunctionManager
():
26
m_constraintMap()
27
{
28
}
29
30
ConstraintFunctionManager::~ConstraintFunctionManager
()
31
{
32
std::multimap<std::string,ConstraintFunction*>::iterator
33
func=m_constraintMap.begin(),
34
func_end=m_constraintMap.end();
35
36
for
(;func!=func_end;func++) {
37
if
((*func).second!=0) {
38
delete
(*func).second;
39
(*func).second=0;
40
}
41
}
42
m_constraintMap.clear();
43
}
44
45
ConstraintFunction
*
ConstraintFunctionManager::
46
getConstraintFunction
(
const
std::string&
id
,
47
MediaId language,
48
const
LimaString
& complement) {
49
// AULOGINIT;
50
// LDEBUG << "getConstraintFunction: "<< id
51
// << "," << complement;
52
53
std::multimap<std::string,ConstraintFunction*>::const_iterator
54
it,it_end;
55
boost::tie(it,it_end)=m_constraintMap.equal_range(
id
);
56
for
(;it!=it_end; it++) {
57
if
((*it).second->getComplementString() == complement
58
&&
static_cast<
MediaId
>
((*it).second->getLanguage()) == language) {
59
// LDEBUG << "getConstraintFunction: function exist: "
60
// << (*it).first << "," << (*it).second->getComplementString()
61
// << "->" << (*it).second;
62
return
(*it).second;
63
}
64
}
65
// LDEBUG << "getConstraintFunction: function does not exist";
66
return
createConstraintFunction
(
id
,language,complement);
67
}
68
69
// not efficient but only for debug
70
bool
ConstraintFunctionManager::
71
getFunctionName
(
const
ConstraintFunction
* functionPtr,
72
std::string&
id
,
73
LimaString
& complement)
const
{
74
std::multimap<std::string,ConstraintFunction*>::const_iterator
75
it=m_constraintMap.begin(),
76
it_end=m_constraintMap.end();
77
for
(;it!=it_end; it++) {
78
if
((*it).second==functionPtr) {
79
id
=(*it).first;
80
complement=(*it).second->getComplementString();
81
return
true
;
82
}
83
}
84
return
false
;
85
}
86
87
ConstraintFunction
*
ConstraintFunctionManager::
88
createConstraintFunction
(
const
std::string&
id
,
89
MediaId language,
90
const
LimaString
& complement) {
91
92
93
ConstraintFunction
* newConstraint=
94
AbstractConstraintFunctionFactory::
95
getFactory
(
id
)->create(language,complement);
96
m_constraintMap.insert(make_pair(
id
,newConstraint));
97
98
#ifdef DEBUG_LP
99
AULOGINIT
;
100
LDEBUG
<<
"ConstraintFunctionManager::createConstraintFunction( id:"
<<
id
101
<<
", language:"
<< language <<
",complement:"
<< complement <<
")->"
<< newConstraint
102
;
103
#endif
104
105
return
newConstraint;
106
}
107
108
109
}
// end namespace
110
}
// end namespace
111
}
// end namespace
LDEBUG
#define LDEBUG
Definition
LimaCommon.h:157
AULOGINIT
#define AULOGINIT
Definition
LinguisticProcessingCommon.h:105
Lima::LinguisticProcessing::Automaton::ConstraintFunctionManager::ConstraintFunctionManager
ConstraintFunctionManager()
Definition
constraintFunctionManager.cpp:25
Lima::LinguisticProcessing::Automaton::ConstraintFunctionManager::createConstraintFunction
ConstraintFunction * createConstraintFunction(const std::string &id, MediaId language, const LimaString &complement=LimaString())
Definition
constraintFunctionManager.cpp:88
Lima::LinguisticProcessing::Automaton::ConstraintFunctionManager::~ConstraintFunctionManager
~ConstraintFunctionManager()
Definition
constraintFunctionManager.cpp:30
Lima::LinguisticProcessing::Automaton::ConstraintFunctionManager::getFunctionName
bool getFunctionName(const ConstraintFunction *functionPtr, std::string &id, LimaString &complement) const
Definition
constraintFunctionManager.cpp:71
Lima::LinguisticProcessing::Automaton::ConstraintFunctionManager::getConstraintFunction
ConstraintFunction * getConstraintFunction(const std::string &id, MediaId language, const LimaString &complement=LimaString())
Definition
constraintFunctionManager.cpp:46
Lima::LinguisticProcessing::Automaton::ConstraintFunction
Definition
constraintFunction.h:37
Lima::RegistrableFactory< AbstractConstraintFunctionFactory >::getFactory
static std::shared_ptr< AbstractConstraintFunctionFactory > getFactory(const std::string &id)
Definition
RegistrableFactory.h:67
constraintFunctionFactory.h
constraintFunctionManager.h
constraintFunction.h
Lima::LinguisticProcessing::Automaton
Definition
andTransition.cpp:27
Lima::LinguisticProcessing
Definition
AbstractLinguisticProcessingClient.h:27
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
Lima::LimaString
QString LimaString
Definition
LimaString.h:33
lima_linguisticprocessing
src
linguisticProcessing
core
Automaton
constraintFunctionManager.cpp
Generated by
1.15.0