Changeset 14:3caa1d3122db in xplcommon for src/xplcommon/Failable.h
- Timestamp:
- 12/29/12 10:03:12 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplcommon/Failable.h
r6 r14 82 82 83 83 //------------------------------------------------------------------------------ 84 85 /** 86 * An object that references another failable object and fails 87 * together with that object. 88 * 89 * The Child class should contain a function named getFailable() 90 * which returns the failable object. 91 */ 92 template <class Child> 93 class FailableReference 94 { 95 public: 96 /** 97 * Indicate if the referenced object has failed. 98 */ 99 bool failed() const; 100 101 /** 102 * Get the error code from the referenced object. 103 */ 104 errorCode_t getErrorCode() const; 105 106 /** 107 * Discard the error code of the referenced object. 108 */ 109 void repair(); 110 }; 111 112 //------------------------------------------------------------------------------ 84 113 // Inline definitions 85 114 //------------------------------------------------------------------------------ … … 119 148 120 149 //------------------------------------------------------------------------------ 150 //------------------------------------------------------------------------------ 151 152 template <class Child> 153 inline bool FailableReference<Child>::failed() const 154 { 155 return static_cast<const Child*>(this)->getFailable().failed(); 156 } 157 158 //------------------------------------------------------------------------------ 159 160 template <class Child> 161 inline errorCode_t FailableReference<Child>::getErrorCode() const 162 { 163 return static_cast<const Child*>(this)->getFailable().getErrorCode(); 164 } 165 166 //------------------------------------------------------------------------------ 167 168 template <class Child> 169 inline void FailableReference<Child>::repair() 170 { 171 static_cast<Child*>(this)->getFailable().repair(); 172 } 173 174 //------------------------------------------------------------------------------ 121 175 122 176 } /* namespace xplcommon */
Note:
See TracChangeset
for help on using the changeset viewer.