fw4spl
LinkDescriptor.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWATOMSPATCH_LINKDESCRIPTOR_HPP__
8 #define __FWATOMSPATCH_LINKDESCRIPTOR_HPP__
9 
10 #include <map>
11 
12 #include "fwCore/BaseObject.hpp"
13 #include "fwAtomsPatch/config.hpp"
14 
15 
16 namespace fwAtomsPatch
17 {
18 
22 class FWATOMSPATCH_CLASS_API LinkDescriptor
23 {
24 
25 public:
26 
28  struct Compare {
29  bool operator() (LinkDescriptor a, LinkDescriptor b) const
30  {
31  return (a.m_originVersion+a.m_targetVersion) < (b.m_originVersion+b.m_targetVersion);
32  }
33  };
34 
36  typedef std::pair< std::string, std::string > VersionIDType;
37 
39  typedef std::map< VersionIDType, VersionIDType > LinksType;
40 
43 
45  LinkDescriptor(const std::string& context, const std::string& originVersion, const std::string& targetVersion,
46  const std::string& patcher, LinksType links, int weight = 1);
47 
49  ~LinkDescriptor();
50 
52  int getWeight() const
53  {
54  return m_weight;
55  }
56 
58  const std::string& getContext() const
59  {
60  return m_context;
61  }
62 
64  const std::string& getOriginVersion() const
65  {
66  return m_originVersion;
67  }
68 
70  const std::string& getTargetVersion() const
71  {
72  return m_targetVersion;
73  }
74 
76  const std::string& getPatcher() const
77  {
78  return m_patcher;
79  }
80 
82  const LinksType& getLinks() const
83  {
84  return m_links;
85  }
86 
87 private:
88 
89  friend class VersionsGraph;
90 
92  int m_weight;
93 
95  std::string m_context;
96 
98  std::string m_originVersion;
99 
101  std::string m_targetVersion;
102 
104  std::string m_patcher;
105 
107  LinksType m_links;
108 };
109 
110 
111 
112 } // fwAtomsPatch
113 
114 #endif /* __FWATOMSPATCH_LINKDESCRIPTOR_HPP__ */
const std::string & getPatcher() const
Returns patcher classname.
const std::string & getOriginVersion() const
Returns origin version.
const std::string & getContext() const
Returns context name.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
Struct used to compare two LinkDescriptor.
const std::string & getTargetVersion() const
Returns target version.
Link descriptor used to identify a link between two versions.
Versions graph description.
int getWeight() const
Returns link weight.
std::pair< std::string, std::string > VersionIDType
VersionID used to link type and version.
std::map< VersionIDType, VersionIDType > LinksType
Links used to link two versions.
const LinksType & getLinks() const
Returns map of links between versions.