TWeightedFeatureWrap.h
Go to the documentation of this file.
1 #ifndef iipr_TFeatureWrap_included
2 #define iipr_TFeatureWrap_included
3 
4 
5 // ACF includes
6 #include "istd/TChangeNotifier.h"
7 
8 // ACF-Solutions includes
10 
11 
12 namespace iipr
13 {
14 
15 
19 template <class BaseObject>
22  public BaseObject
23 {
24 public:
26  typedef BaseObject BaseClass2;
27 
28  TWeightedFeatureWrap(double weight = 1.0);
29 
30  double GetWeight() const;
31  void SetWeight(double weight);
32 
33  // reimplemented (iser::ISerializable)
34  virtual bool Serialize(iser::IArchive& archive);
35 
36  // reimplemented (istd::IChangeable)
37  virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode);
38 
39 protected:
40  double m_weight;
41 };
42 
43 
44 // public methods
45 
46 template <class BaseObject>
48  :m_weight(weight)
49 {
50 }
51 
52 
53 template <class BaseObject>
55 {
56  return m_weight;
57 }
58 
59 
60 template <class BaseObject>
62 {
63  m_weight = weight;
64 }
65 
66 
67 // reimplemented (iser::ISerializable)
68 
69 template <class BaseObject>
71 {
72  istd::CChangeNotifier notifier(archive.IsStoring()? NULL: this);
73 
74  bool retVal = true;
75 
76  retVal = retVal && BaseClass::Serialize(archive);
77  retVal = retVal && BaseClass2::Serialize(archive);
78 
79  iser::CArchiveTag weightTag("Weight", "Weight");
80  retVal = retVal && archive.BeginTag(weightTag);
81  retVal = retVal && archive.Process(m_weight);
82  retVal = retVal && archive.EndTag(weightTag);
83 
84  return retVal;
85 }
86 
87 
88 // reimplemented (istd::IChangeable)
89 
90 template <class BaseObject>
91 bool TWeightedFeatureWrap<BaseObject>::CopyFrom(const IChangeable& object, CompatibilityMode mode)
92 {
93  const TWeightedFeatureWrap<BaseObject>* objectPtr = dynamic_cast<const TWeightedFeatureWrap<BaseObject>*>(&object);
94  if (objectPtr != NULL){
95  m_weight = objectPtr->GetWeight();
96  }
97 
98  return BaseObject::CopyFrom(object, mode);
99 }
100 
101 
102 } // namespace iipr
103 
104 
105 #endif // !iipr_TFeatureWrap_included
106 
107 
imeas::CSimpleNumericValue BaseClass
TWeightedFeatureWrap(double weight=1.0)
virtual bool Serialize(iser::IArchive &archive)
Basic implementation of imeas::INumericValue interface.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode)
#define NULL
Wrapper allowing to create feature object from some another serializable one.

© 2007-2011 Witold Gantzke and Kirill Lepskiy