LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AnnotationData.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
18#ifndef WIN32
19#include <cstdint> //uint32_t
20#endif
21#include "AnnotationData.h"
23
24//using namespace boost;
25
26namespace Lima
27{
28namespace Common
29{
30namespace AnnotationGraphs
31{
32
43{
44public:
45 virtual int dump(std::ostream&, GenericAnnotation&) const override;
46};
47
48
49
51{
52 friend class AnnotationData;
53
56
59
61 AnnotationGraph m_graph;
62
64 Lima::StringsPool m_pool;
65
67 std::map< uint64_t, const AnnotationData::Dumper* > m_dumpFunctions;
68
76 std::map<StringsPoolIndex, std::multimap<AnnotationGraphVertex, AnnotationGraphVertex> > m_matchings;
77
78 CVertexAGGannotPropertyMap m_mapCVertexAGGannotPropertyMap;
79 CVertexAGSannotPropertyMap m_mapCVertexAGSannotPropertyMap;
80 VertexAGIannotPropertyMap m_mapVertexAGIannotPropertyMap;
81 VertexAGSannotPropertyMap m_mapVertexAGSannotPropertyMap;
82 EdgeAGIannotPropertyMap m_mapEdgeAGIannotPropertyMap;
83 CEdgeAGIannotPropertyMap m_mapCEdgeAGIannotPropertyMap;
84 VertexAGGannotPropertyMap m_mapVertexAGGannotPropertyMap;
85 EdgeAGSannotPropertyMap m_mapEdgeAGSannotPropertyMap;
86 CEdgeAGSannotPropertyMap m_mapCEdgeAGSannotPropertyMap;
87 EdgeAGGannotPropertyMap m_mapEdgeAGGannotPropertyMap;
88 CEdgeAGGannotPropertyMap m_mapCEdgeAGGannotPropertyMap;
89 CVertexAGIannotPropertyMap m_mapCVertexAGIannotPropertyMap;
90};
91
92
93AnnotationDataPrivate::AnnotationDataPrivate() :
94 m_graph(),
95 m_pool(),
96 m_dumpFunctions(),
97 m_matchings(),
98 m_mapCVertexAGGannotPropertyMap( get(vertex_gannot, (const AnnotationGraph&)m_graph) ),
99 m_mapCVertexAGSannotPropertyMap( get(vertex_sannot, (const AnnotationGraph&)m_graph) ),
100 m_mapVertexAGIannotPropertyMap( get(vertex_iannot, m_graph) ),
101 m_mapVertexAGSannotPropertyMap( get(vertex_sannot, m_graph) ),
102 m_mapEdgeAGIannotPropertyMap( get(edge_iannot, m_graph) ),
103 m_mapCEdgeAGIannotPropertyMap( get(edge_iannot, (const AnnotationGraph&)m_graph) ),
104 m_mapVertexAGGannotPropertyMap( get(vertex_gannot, m_graph) ),
105 m_mapEdgeAGSannotPropertyMap( get(edge_sannot, m_graph) ),
106 m_mapCEdgeAGSannotPropertyMap( get(edge_sannot, (const AnnotationGraph&)m_graph) ),
107 m_mapEdgeAGGannotPropertyMap( get(edge_gannot, m_graph) ),
108 m_mapCEdgeAGGannotPropertyMap( get(edge_gannot, (const AnnotationGraph&)m_graph) ),
109 m_mapCVertexAGIannotPropertyMap( get(vertex_iannot, (const AnnotationGraph&)m_graph) )
110{
111}
112
113AnnotationDataPrivate::~AnnotationDataPrivate()
114{
115 for (std::map< uint64_t, const AnnotationData::Dumper* >::const_iterator it=m_dumpFunctions.begin();
116 it!=m_dumpFunctions.end();
117 it++)
118 {
119 delete it->second;
120 }
121}
122
123
124
129
131{
132 delete m_d;
133}
134
135AnnotationGraph& AnnotationData::getGraph() { return m_d->m_graph; }
136const AnnotationGraph& AnnotationData::getGraph() const { return m_d->m_graph; }
140const LimaString& AnnotationData::annotationName(uint64_t annotationId) const
141{
142 return m_d->m_pool[static_cast<StringsPoolIndex>(annotationId)];
143}
144
147{
148 return m_d->m_pool[s];
149}
150
151
153{
154 return add_vertex(m_d->m_graph);
155}
156
158{
159#ifdef DEBUG_LP
160 AGLOGINIT;
161 LDEBUG << "Creating annotation edge " << s << " -> " << t;
162#endif
163 return add_edge(s, t, m_d->m_graph).first;
164}
165
166
167void AnnotationData::annotate(AnnotationGraphVertex v, const LimaString& annot, uint64_t value)
168{
169 /*
170 Critical function : comment logging messages
171 */
172 annotate(v, m_d->m_pool[annot], value);
173}
174
176{
177 /*
178 Critical function : comment logging messages
179 */
180 annotate(v, m_d->m_pool[annot], value);
181}
182
184{
185 /*
186 Critical function : comment logging messages
187 */
188 annotate(v, m_d->m_pool[annot], value);
189}
190
191
193{
194 bool ok; AnnotationGraphEdge e;
195 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
196 if (!ok) e = createAnnotationEdge(vs, vt);
197 annotate(e, m_d->m_pool[annot], value);
198}
199
201{
202 bool ok; AnnotationGraphEdge e;
203 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
204 if (!ok) e = createAnnotationEdge(vs, vt);
205 annotate(e, m_d->m_pool[annot], value);
206}
207
209{
210 bool ok; AnnotationGraphEdge e;
211 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
212 if (!ok) e = createAnnotationEdge(vs, vt);
213 annotate(e, m_d->m_pool[annot], value);
214}
215
216
217void AnnotationData::annotate(AnnotationGraphEdge e, const LimaString& annot, uint64_t value)
218{
219 /*
220 Critical function : comment logging messages
221 */
222// AGLOGINIT;
223// LDEBUG << "Annotating " << e << " ("<<annot<<") : " << value;
224 annotate(e, m_d->m_pool[annot], value);
225}
226
228{
229 /*
230 Critical function : comment logging messages
231 */
232// AGLOGINIT;
233// LDEBUG << "Annotating " << e << " ("<<annot<<") : " << value;
234 annotate(e, m_d->m_pool[annot], value);
235}
236
238{
239 /*
240 Critical function : comment logging messages
241 */
242// AGLOGINIT;
243// LDEBUG << "Annotating " << e << " ("<<annot<<") : GA";
244 annotate(e, m_d->m_pool[annot], value);
245}
246
247
249{
250 const uint64_t idx = const_cast<AnnotationData*>(this)->m_d->m_pool[annot];
251 return intAnnotation(v, idx);
252}
253
255{
256 return stringAnnotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
257}
258
260{
261 return annotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
262}
263
265{
266 return annotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
267}
268
270{
271 const uint64_t idx = const_cast<AnnotationData*>(this)->m_d->m_pool[annot];
272 return intAnnotation(v1, v2, idx);
273}
274
276{
277 return stringAnnotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
278}
279
281{
282 return annotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
283}
284
286{
287 return annotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
288}
289
290
292{
293 return intAnnotation(e, m_d->m_pool[annot]);
294}
295
297{
298 return stringAnnotation(e, m_d->m_pool[annot]);
299}
300
302{
303 return annotation(e, m_d->m_pool[annot]);
304}
305
307{
308 return annotation(e, m_d->m_pool[annot]);
309}
310
311
313void AnnotationData::annotate(AnnotationGraphVertex v, uint64_t annot, uint64_t value)
314{
315 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
316 {
317 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
318 }
319 m_d->m_mapVertexAGIannotPropertyMap[v][annot] = value;
320#ifdef DEBUG_LP
321 AGLOGINIT;
322 LDEBUG << "Annotating " << v << " ("<<m_d->m_pool[StringsPoolIndex(annot)]<<") : " << value;
323#endif
324}
325
326void AnnotationData::annotate(AnnotationGraphVertex v, uint64_t annot, const LimaString& value)
327{
328 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
329 {
330 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
331 }
332 m_d->m_mapVertexAGSannotPropertyMap[v][annot] = value;
333#ifdef DEBUG_LP
334 AGLOGINIT;
335 LDEBUG << "Annotating " << v << " ("<<m_d->m_pool[StringsPoolIndex(annot)]<<") : " << value;
336#endif
337}
338
340{
341 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
342 {
343 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
344 }
345 if (num_vertices(m_d->m_graph) <= v)
346 {
347 std::ostringstream oss;
348 oss << "Trying to annotate an inexisting vertex: " << v
349 << ". Graph size in vertices is: " << num_vertices(m_d->m_graph) << std::endl;
350 throw std::range_error(oss.str());
351 }
352 std::map< uint64_t, GenericAnnotation > m = m_d->m_mapVertexAGGannotPropertyMap[v];
353 m_d->m_mapVertexAGGannotPropertyMap[v][annot] = value;
354#ifdef DEBUG_LP
355 AGLOGINIT;
356 LDEBUG << "Annotating " << v << " ("<< m_d->m_pool[StringsPoolIndex(annot)] <<") : GA";
357#endif
358}
359
360
361void AnnotationData::annotate(AnnotationGraphVertex vs, AnnotationGraphVertex vt, uint64_t annot, uint64_t value)
362{
363 bool ok; AnnotationGraphEdge e;
364 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
365 if (!ok) e = createAnnotationEdge(vs, vt);
366 annotate(e, annot, value);
367#ifdef DEBUG_LP
368 AGLOGINIT;
369 LDEBUG << "Annotating " << vs << " -> " << vt << " ("<<m_d->m_pool[StringsPoolIndex(annot)]<<") : " << value;
370#endif
371}
372
374{
375 bool ok; AnnotationGraphEdge e;
376 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
377 if (!ok) e = createAnnotationEdge(vs, vt);
378 annotate(e, annot, value);
379}
380
382{
383 bool ok; AnnotationGraphEdge e;
384 boost::tie(e, ok) = edge(vs,vt,m_d->m_graph);
385 if (!ok) e = createAnnotationEdge(vs, vt);
386 annotate(e, annot, value);
387}
388
389
390void AnnotationData::annotate(AnnotationGraphEdge e, uint64_t annot, uint64_t value)
391{
392 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
393 {
394 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
395 }
396 m_d->m_mapEdgeAGIannotPropertyMap[e][annot] = value;
397}
398
399void AnnotationData::annotate(AnnotationGraphEdge e, uint64_t annot, const LimaString& value)
400{
401 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
402 {
403 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
404 }
405 m_d->m_mapEdgeAGSannotPropertyMap[e][annot] = value;
406}
407
409{
410 if (m_d->m_dumpFunctions.find(annot) == m_d->m_dumpFunctions.end())
411 {
412 m_d->m_dumpFunctions[annot] = new DummyDumpFunction();
413 }
414 m_d->m_mapEdgeAGGannotPropertyMap[e][annot] = value;
415}
416
417
419{
420 return m_d->m_mapVertexAGIannotPropertyMap[v][annot];
421}
422
424{
425 return m_d->m_mapVertexAGSannotPropertyMap[v][annot];
426}
427
429{
430 return m_d->m_mapVertexAGGannotPropertyMap[v][annot];
431}
432
434{
435 return m_d->m_mapVertexAGGannotPropertyMap[v][annot];
436}
437
438
440{
441 return m_d->m_mapEdgeAGIannotPropertyMap[e][annot];
442}
443
445{
446 return m_d->m_mapEdgeAGSannotPropertyMap[e][annot];
447}
448
450{
451 return (*(m_d->m_mapCEdgeAGGannotPropertyMap[e].find(annot))).second;
452}
453
455{
456 return m_d->m_mapEdgeAGGannotPropertyMap[e][annot];
457}
458
459
462{
463 bool ok; AnnotationGraphEdge e;
464 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
465 if (!ok)
466 {
467 std::ostringstream oss;
468 oss << "Error trying to access to inexistant edge " << v1 << " -> " << v2;
469 throw std::runtime_error(oss.str().c_str());
470 }
471 return (*(m_d->m_mapCEdgeAGIannotPropertyMap[e].find(annot))).second;
472}
473
475{
476 bool ok; AnnotationGraphEdge e;
477 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
478 if (!ok)
479 {
480 std::ostringstream oss;
481 oss << "Error trying to access to inexistant edge " << v1 << " -> " << v2;
482 throw std::runtime_error(oss.str().c_str());
483 }
484 return (*(m_d->m_mapCEdgeAGSannotPropertyMap[e].find(annot))).second;
485}
486
488{
489 bool ok; AnnotationGraphEdge e;
490 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
491 if (!ok)
492 {
493 std::ostringstream oss;
494 oss << "Error trying to access to inexistant edge " << v1 << " -> " << v2;
495 throw std::runtime_error(oss.str().c_str());
496 }
497 if (m_d->m_mapCEdgeAGGannotPropertyMap[e].find(annot) == m_d->m_mapCEdgeAGGannotPropertyMap[e].end())
498 {
499 std::ostringstream oss;
500 oss << "Error trying to access to inexistant edge annotation" << v1 << " -> " << v2 << ", " << annot;
501 throw std::runtime_error(oss.str().c_str());
502 }
503 return (*(m_d->m_mapCEdgeAGGannotPropertyMap[e].find(annot))).second;
504}
505
507{
508 bool ok; AnnotationGraphEdge e;
509 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
510 if (!ok)
511 {
512 std::ostringstream oss;
513 oss << "Error trying to access to inexistant edge " << v1 << " -> " << v2;
514 throw std::runtime_error(oss.str().c_str());
515 }
516 if (m_d->m_mapEdgeAGGannotPropertyMap[e].find(annot) == m_d->m_mapEdgeAGGannotPropertyMap[e].end())
517 {
518 std::ostringstream oss;
519 oss << "Error trying to access to inexistant edge annotation" << v1 << " -> " << v2 << ", " << annot;
520 throw std::runtime_error(oss.str().c_str());
521 }
522 return (*(m_d->m_mapEdgeAGGannotPropertyMap[e].find(annot))).second;
523}
525
526
527
529{
530 return hasIntAnnotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
531}
532
534{
535 return hasStringAnnotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
536}
537
539{
540 return hasAnnotation(v, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
541}
542
544{
545 return hasIntAnnotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
546}
547
549{
550 return hasStringAnnotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
551}
552
554{
555 return hasAnnotation(v1, v2, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
556}
557
559{
560 return hasIntAnnotation(e, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
561}
562
564{
565 return hasStringAnnotation(e, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
566}
567
569{
570 return hasAnnotation(e, const_cast<AnnotationData*>(this)->m_d->m_pool[annot]);
571}
572
574{
575 return (m_d->m_mapCVertexAGIannotPropertyMap[v].find(annot) != m_d->m_mapCVertexAGIannotPropertyMap[v].end());
576}
577
579{
580 return (m_d->m_mapCVertexAGSannotPropertyMap[v].find(annot) != m_d->m_mapCVertexAGSannotPropertyMap[v].end());
581}
582
584{
585 return (m_d->m_mapCVertexAGGannotPropertyMap[v].find(annot) != m_d->m_mapCVertexAGGannotPropertyMap[v].end());
586}
587
589{
590 bool ok; AnnotationGraphEdge e;
591 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
592 if (!ok) return false;
593 return hasIntAnnotation(e, annot);
594}
595
597{
598 bool ok; AnnotationGraphEdge e;
599 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
600 if (!ok) return false;
601 return hasStringAnnotation(e, annot);
602}
603
605{
606 bool ok; AnnotationGraphEdge e;
607 boost::tie(e, ok) = edge(v1,v2,m_d->m_graph);
608 if (!ok) return false;
609 return hasAnnotation(e, annot);
610}
611
613{
614 return (m_d->m_mapCEdgeAGIannotPropertyMap[e].find(annot) != m_d->m_mapCEdgeAGIannotPropertyMap[e].end());
615}
616
618{
619 return (m_d->m_mapCEdgeAGSannotPropertyMap[e].find(annot) != m_d->m_mapCEdgeAGSannotPropertyMap[e].end());
620}
621
623{
624 return (m_d->m_mapCEdgeAGGannotPropertyMap[e].find(annot) != m_d->m_mapCEdgeAGGannotPropertyMap[e].end());
625}
626
627
628
629
630
631
632void AnnotationData::dumpFunction(const std::string& annot, const AnnotationData::Dumper* f)
633{
634 LimaString wannot = QString::fromStdString(annot);
635 uint64_t annotId = annotationId(wannot);
636 if (m_d->m_dumpFunctions.find(annotId) != m_d->m_dumpFunctions.end())
637 {
638 AGLOGINIT;
639 LWARN << "Replacing dump function for " << annot << " annotation. Deleting old one";
640 delete m_d->m_dumpFunctions[annotId];
641 }
642 m_d->m_dumpFunctions[annotId] = f;
643}
644
646{
647 LimaString wannot = QString::fromStdString(annot);
648 uint64_t annotId = annotationId(wannot);
649 if (m_d->m_dumpFunctions.find(annotId) == m_d->m_dumpFunctions.end())
650 {
651 return 0;
652 }
653 else
654 {
655 return m_d->m_dumpFunctions[annotId];
656 }
657}
658
660{
661 return m_d->m_dumpFunctions[annot];
662}
663
671int DummyDumpFunction::dump(std::ostream& os, GenericAnnotation&) const
672{
673 os << "no_dump_function_defined";
674 return SUCCESS_ID;
675}
676
677void AnnotationData::addMatching(const StringsPoolIndex& direction, AnnotationGraphVertex firstVx,
678 AnnotationGraphVertex secondVx)
679{
680 m_d->m_matchings[direction].insert(std::make_pair(firstVx,secondVx));
681}
682
684const std::map<StringsPoolIndex, std::multimap<AnnotationGraphVertex, AnnotationGraphVertex> >& AnnotationData::matchings() const {return m_d->m_matchings;}
685
686
687void AnnotationData::addMatching(const std::string& first,
688 AnnotationGraphVertex firstVx,
689 const std::string& second,
690 AnnotationGraphVertex secondVx)
691{
692#ifdef DEBUG_LP
693 AGLOGINIT;
694 LDEBUG << "AnnotationData::addMatching " << first << firstVx
695 << second << secondVx;
696#endif
697
698 addMatching( m_d->m_pool[ QString::fromStdString(first + second) ],
699 firstVx, secondVx);
700 addMatching( m_d->m_pool[ QString::fromStdString(second + first) ],
701 secondVx, firstVx);
702}
703
707std::set< AnnotationGraphVertex > AnnotationData::matches(const std::string& first,
708 AnnotationGraphVertex firstVx,
709 const std::string& second) const
710 {
711 return matches( m_d->m_pool[ QString::fromStdString(first + second) ], firstVx);
712 }
713
716bool AnnotationData::isMatching(const std::string& first, AnnotationGraphVertex firstVx,
717 const std::string& second, AnnotationGraphVertex secondVx) const
718{
719 return isMatching( m_d->m_pool[ QString::fromStdString(first + second) ], firstVx, secondVx);
720}
721
722void AnnotationData::addMatching(const StringsPoolIndex& first, AnnotationGraphVertex firstVx,
723 const StringsPoolIndex& second, AnnotationGraphVertex secondVx)
724{
725 addMatching( m_d->m_pool[ m_d->m_pool[first] + m_d->m_pool[second] ], firstVx, secondVx);
726 addMatching( m_d->m_pool[ m_d->m_pool[second] + m_d->m_pool[first] ], secondVx, firstVx);
727}
728
729std::set< AnnotationGraphVertex > AnnotationData::matches(const StringsPoolIndex& first,
730 AnnotationGraphVertex firstVx,
731 const StringsPoolIndex& second) const
732 {
733 return matches( m_d->m_pool[ m_d->m_pool[first] + m_d->m_pool[second] ], firstVx);
734 }
735
736bool AnnotationData::isMatching(const StringsPoolIndex& first, AnnotationGraphVertex firstVx,
737 const StringsPoolIndex& second, AnnotationGraphVertex secondVx) const
738{
739 return isMatching( m_d->m_pool[ m_d->m_pool[first] + m_d->m_pool[second] ], firstVx, secondVx);
740}
741
742std::set< AnnotationGraphVertex > AnnotationData::matches(const StringsPoolIndex& direction,
743 AnnotationGraphVertex firstVx) const
744{
745 if (m_d->m_matchings.find(direction) == m_d->m_matchings.end())
746 {
747 return std::set< AnnotationGraphVertex >();
748 }
749 else
750 {
751 std::set< AnnotationGraphVertex > result;
752 auto range = m_d->m_matchings[direction].equal_range(firstVx);
753 for (; range.first != range.second; range.first++)
754 {
755 result.insert( (*(range.first)).second);
756 }
757 return result;
758 }
759}
760
761bool AnnotationData::isMatching(const StringsPoolIndex& direction,
762 AnnotationGraphVertex firstVx,
763 AnnotationGraphVertex secondVx) const
764{
765 if (m_d->m_matchings.find(direction) == m_d->m_matchings.end())
766 {
767 return false;
768 }
769 else
770 {
771 std::pair< std::multimap<AnnotationGraphVertex, AnnotationGraphVertex>::iterator, std::multimap<AnnotationGraphVertex, AnnotationGraphVertex>::iterator > range;
772 range = const_cast< std::map< StringsPoolIndex, std::multimap<AnnotationGraphVertex, AnnotationGraphVertex> >& >(m_d->m_matchings)[direction].equal_range(firstVx);
773 for (; range.first != range.second; range.first++)
774 {
775 if ( (*(range.first)).second == secondVx )
776 {
777 return true;
778 }
779 }
780 return false;
781 }
782
783}
784
787 std::set< std::string >& excepted)
788{
789 std::set< uint64_t > iexcepted;
790 std::set< std::string >::const_iterator eit, eit_end;
791 eit=excepted.begin(); eit_end = excepted.end();
792 for (; eit!=eit_end; eit++)
793 {
794 iexcepted.insert(m_d->m_pool[QString::fromStdString(*eit)]);
795 }
796
797 AGIannotProp& srcimap = m_d->m_mapVertexAGIannotPropertyMap[src];
798 AGIannotProp& tgtimap = m_d->m_mapVertexAGIannotPropertyMap[tgt];
799 for (AGIannotProp::const_iterator iamit=srcimap.begin();
800 iamit != srcimap.end(); iamit++)
801 {
802 if (iexcepted.find((*iamit).first) == iexcepted.end())
803 {
804 tgtimap.insert(*iamit);
805 }
806 }
807
808 std::map< uint64_t, LimaString >& srcsmap = m_d->m_mapVertexAGSannotPropertyMap[src];
809 std::map< uint64_t, LimaString >& tgtsmap = m_d->m_mapVertexAGSannotPropertyMap[tgt];
810 for (std::map< uint64_t, LimaString >::const_iterator samit=srcsmap.begin();
811 samit != srcsmap.end(); samit++)
812 {
813 if (iexcepted.find((*samit).first) == iexcepted.end())
814 {
815 tgtsmap.insert(*samit);
816 }
817 }
818
819 std::map< uint64_t, GenericAnnotation >& srcmap = m_d->m_mapVertexAGGannotPropertyMap[src];
820 std::map< uint64_t, GenericAnnotation >& tgtmap = m_d->m_mapVertexAGGannotPropertyMap[tgt];
821 for (std::map< uint64_t, GenericAnnotation >::const_iterator amit=srcmap.begin();
822 amit != srcmap.end(); amit++)
823 {
824 if (iexcepted.find((*amit).first) == iexcepted.end())
825 {
826 tgtmap.insert(*amit);
827 }
828 }
829
830}
831
832} // closing namespace AnnotationGraphs
833} // closing namespace Common
834} // closing namespace Lima
This file is the main header file for the data related to annotation graphs.
@ edge_sannot
@ vertex_gannot
@ vertex_sannot
@ edge_gannot
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, AGVertexProperties, AGEdgeProperties > AnnotationGraph
The graph class.
@ vertex_iannot
@ edge_iannot
std::map< uint64_t, uint64_t > AGIannotProp
Property to annotate vertices with integer values.
#define LWARN
Definition LimaCommon.h:160
#define AGLOGINIT
Definition LimaCommon.h:200
#define LDEBUG
Definition LimaCommon.h:157
#define LIMA_ANNOTATIONGRAPH_EXPORT
Holds an annotation graph and gives an API to manipulate it.
void addMatching(const std::string &first, AnnotationGraphVertex firstVx, const std::string &second, AnnotationGraphVertex secondVx)
Adds a symetric matching between two vertices of two graphs identified by the two string parameters.
uint64_t intAnnotation(AnnotationGraphVertex v1, AnnotationGraphVertex v2, const LimaString &annot) const
std::set< AnnotationGraphVertex > matches(const std::string &first, AnnotationGraphVertex firstVx, const std::string &second) const
Gets the set of vertices matched in the second graph by the given vertex of the first graph.
const std::map< StringsPoolIndex, std::multimap< AnnotationGraphVertex, AnnotationGraphVertex > > & matchings() const
Access to the underlying raw matching structure.
const GenericAnnotation & annotation(AnnotationGraphVertex v1, AnnotationGraphVertex v2, const LimaString &annot) const
const LimaString & stringAnnotation(AnnotationGraphVertex v1, AnnotationGraphVertex v2, const LimaString &annot) const
AnnotationGraphVertex createAnnotationVertex()
Creates a new annotation vertex in the graph.
void cloneAnnotations(AnnotationGraphVertex src, AnnotationGraphVertex tgt, std::set< std::string > &excepted)
@briefs copies all the annotations of the source annotation vertex onto the target annotation vertex,...
uint64_t annotationId(const LimaString &s)
Gives the id of an annotation name.
bool isMatching(const std::string &first, AnnotationGraphVertex firstVx, const std::string &second, AnnotationGraphVertex secondVx) const
Tests if the two given vertices are matching in the two given graphs.
AnnotationGraphEdge createAnnotationEdge(AnnotationGraphVertex s, AnnotationGraphVertex t)
Creates a new annotation edge in the graph.
const LimaString & annotationName(uint64_t annotationId) const
Gives the name of an annotation id.
Definition of a dummy function suitable to be used as a dumper for the annotations of an annotation g...
virtual int dump(std::ostream &, GenericAnnotation &) const override
Definition of a dummy function suitable to be used as a dumper for the annotations of an annotation g...
This class allows to convert any object into an annotation by inheritance.
void dumpFunction(const std::string &annot, const Dumper *f)
boost::property_map< AnnotationGraph, edge_gannot_t >::type EdgeAGGannotPropertyMap
boost::property_map< AnnotationGraph, edge_iannot_t >::type EdgeAGIannotPropertyMap
boost::property_map< AnnotationGraph, vertex_iannot_t >::const_type CVertexAGIannotPropertyMap
boost::property_map< AnnotationGraph, edge_iannot_t >::const_type CEdgeAGIannotPropertyMap
boost::property_map< AnnotationGraph, edge_sannot_t >::type EdgeAGSannotPropertyMap
boost::property_map< AnnotationGraph, vertex_iannot_t >::type VertexAGIannotPropertyMap
AnnotationGraph::edge_descriptor AnnotationGraphEdge
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
boost::property_map< AnnotationGraph, edge_gannot_t >::const_type CEdgeAGGannotPropertyMap
boost::property_map< AnnotationGraph, edge_sannot_t >::const_type CEdgeAGSannotPropertyMap
boost::property_map< AnnotationGraph, vertex_sannot_t >::const_type CVertexAGSannotPropertyMap
boost::property_map< AnnotationGraph, vertex_gannot_t >::const_type CVertexAGGannotPropertyMap
boost::property_map< AnnotationGraph, vertex_sannot_t >::type VertexAGSannotPropertyMap
boost::property_map< AnnotationGraph, vertex_gannot_t >::type VertexAGGannotPropertyMap
bool hasStringAnnotation(AnnotationGraphVertex v, const LimaString &annot) const
bool hasIntAnnotation(AnnotationGraphVertex v, const LimaString &annot) const
bool hasAnnotation(AnnotationGraphVertex v, const LimaString &annot) const
void annotate(AnnotationGraphVertex v, const LimaString &annot, uint64_t value)
NAUTITIA.
@ SUCCESS_ID
Definition LimaCommon.h:237
QString LimaString
Definition LimaString.h:33