LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AbstractProcessingClientHandler.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#ifndef ABSTRACTPROCESSINGCLIENTHANDLER_H
7#define ABSTRACTPROCESSINGCLIENTHANDLER_H
8
9#include <sstream>
13
14namespace Lima {
15
17{
18 public:
20
21 inline virtual void setAnalysisClient(const std::string& clientId,
22 std::shared_ptr< AbstractProcessingClient > client)
23 {
24 if (m_clients.find(clientId)!=m_clients.end())
25 {
26// ABSTRACTPROCESSINGCLIENTLOGINIT;
27// LERROR << "Handler for handlerId '" << handlerId << "' already exists !" ;
28// throw LimaException();
29 m_clients.erase(clientId);
30 }
31 m_clients.insert(std::make_pair(clientId, client));
32 }
33
34 inline virtual std::shared_ptr< AbstractProcessingClient > getAnalysisClient(const std::string& clientId)
35 {
36 if (m_clients.find(clientId)==m_clients.end())
37 {
39 LIMA_EXCEPTION("AbstractProcessingClientHandler::getAnalysisClient no Client for clientId "
40 << clientId.c_str());
41 }
42 return m_clients[clientId];
43 }
44
45 inline virtual std::map<std::string, std::shared_ptr< AbstractProcessingClient > > getAnalysisClients() const
46 {
47 return m_clients;
48 };
49 inline virtual void setAnalysisClients(std::map<std::string, std::shared_ptr< AbstractProcessingClient > > clients)
50 {
51 m_clients=clients;
52 };
53
54 virtual void handleProc(const std::string& tagName,
55 const std::string& content,
56 const std::map<std::string,std::string>& metaData,
57 const std::string& pipeline,
58 const std::map<std::string, AbstractAnalysisHandler*>& handlers = std::map<std::string, AbstractAnalysisHandler*>(),
59 const std::set<std::string>& inactiveUnits = std::set<std::string>())
60 {
62 auto& r = *getAnalysisClient(tagName).get();
63 LDEBUG << "handleProc("<<tagName<<") gets "
64 << (void*)getAnalysisClient(tagName).get() <<" class: "
65 << typeid(r).name();
66 getAnalysisClient(tagName)->analyze(content,
67 metaData,
68 pipeline,
69 handlers,
70 inactiveUnits);
71 }
72
73private:
75 std::map<std::string, std::shared_ptr< AbstractProcessingClient > > m_clients;
76};
77
78}
79
80#endif
#define LIMA_EXCEPTION(X)
This macro writes the message X to a previously configured error stream before throwing a LimaExcepti...
Definition LimaCommon.h:293
#define ABSTRACTPROCESSINGCLIENTLOGINIT
Definition LimaCommon.h:199
#define LDEBUG
Definition LimaCommon.h:157
virtual void handleProc(const std::string &tagName, const std::string &content, const std::map< std::string, std::string > &metaData, const std::string &pipeline, const std::map< std::string, AbstractAnalysisHandler * > &handlers=std::map< std::string, AbstractAnalysisHandler * >(), const std::set< std::string > &inactiveUnits=std::set< std::string >())
virtual void setAnalysisClients(std::map< std::string, std::shared_ptr< AbstractProcessingClient > > clients)
virtual void setAnalysisClient(const std::string &clientId, std::shared_ptr< AbstractProcessingClient > client)
virtual std::shared_ptr< AbstractProcessingClient > getAnalysisClient(const std::string &clientId)
virtual std::map< std::string, std::shared_ptr< AbstractProcessingClient > > getAnalysisClients() const
NAUTITIA.