TVersionInfoBase.h
Go to the documentation of this file.
1 #ifndef ibase_TVersionInfoBase_included
2 #define ibase_TVersionInfoBase_included
3 
4 
5 // ACF includes
6 #include <iser/IVersionInfo.h>
7 #include <ilog/TLoggerCompWrap.h>
8 #include <istd/AcfVersion.h>
9 
10 
11 namespace ibase
12 {
13 
14 
18 template <class BaseComponent>
19 class TVersionInfoBase: public BaseComponent, virtual public iser::IVersionInfo
20 {
21 public:
22  typedef BaseComponent BaseClass;
23 
24  I_BEGIN_BASE_COMPONENT(TVersionInfoBase);
25  I_REGISTER_INTERFACE(iser::IVersionInfo);
26  I_ASSIGN(m_slaveVersionInfoCompPtr, "SlaveVersionInfo", "Slave version info, unknown version information requests will be delegated here", false, "SlaveVersionInfo");
27  I_END_COMPONENT;
28 
29  // reimplemented (iser::IVersionInfo)
30  virtual bool GetVersionNumber(int versionId, quint32& result) const;
31  virtual QString GetVersionIdDescription(int versionId) const;
32  virtual VersionIds GetVersionIds() const;
33  virtual QString GetEncodedVersionName(int versionId, quint32 versionNumber) const;
34 
35 private:
36  I_REF(iser::IVersionInfo, m_slaveVersionInfoCompPtr);
37 };
38 
39 
40 // public methods
41 
42 // reimplemented (iser::IVersionInfo)
43 
44 template <class BaseComponent>
45 bool TVersionInfoBase<BaseComponent>::GetVersionNumber(int versionId, quint32& result) const
46 {
47  if (m_slaveVersionInfoCompPtr.IsValid()){
48  return m_slaveVersionInfoCompPtr->GetVersionNumber(versionId, result);
49  }
50  else if (versionId == iser::IVersionInfo::AcfVersionId){
51  result = istd::RS_USE_VERSION;
52 
53  return true;
54  }
55 
56  result = 0xffffffff;
57 
58  return false;
59 }
60 
61 
62 template <class BaseComponent>
64 {
65  if (m_slaveVersionInfoCompPtr.IsValid()){
66  return m_slaveVersionInfoCompPtr->GetVersionIdDescription(versionId);
67  }
68 
69  return "";
70 }
71 
72 
73 template <class BaseComponent>
75 {
76  VersionIds retVal;
77  if (m_slaveVersionInfoCompPtr.IsValid()){
78  retVal = m_slaveVersionInfoCompPtr->GetVersionIds();
79  }
80 
81  return retVal;
82 }
83 
84 
85 template <class BaseComponent>
86 QString TVersionInfoBase<BaseComponent>::GetEncodedVersionName(int versionId, quint32 versionNumber) const
87 {
88  QString retVal;
89 
90  if (m_slaveVersionInfoCompPtr.IsValid()){
91  retVal = m_slaveVersionInfoCompPtr->GetEncodedVersionName(versionId, versionNumber);
92  }
93  else{
94  retVal = QString("<") + QString("%1").arg(versionNumber) + ">";
95  }
96 
97  return retVal;
98 }
99 
100 
101 // Standard definitions
104 
105 
106 } // namespace ibase
107 
108 
109 #endif // !ibase_TVersionInfoBase_included
110 
111 
QSet< int > VersionIds
Definition: IVersionInfo.h:45
TVersionInfoBase< icomp::CComponentBase > CVersionInfoCompBase
Provides access to version information.
Definition: IVersionInfo.h:22
Generic implementation for a version component.
virtual VersionIds GetVersionIds() const
Get list of version ID's.
virtual QString GetVersionIdDescription(int versionId) const
Get description of version ID.
virtual QString GetEncodedVersionName(int versionId, quint32 versionNumber) const
Encode version number to human readable form.
TVersionInfoBase< ilog::CLoggerComponentBase > CVersionInfoLoggerCompBase
virtual bool GetVersionNumber(int versionId, quint32 &result) const
Get version of archived stream for specific versioning type.

© 2007-2017 Witold Gantzke and Kirill Lepskiy