00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_STATUSCONTAINER_HPP
00017 #define TORC_GENERIC_OM_STATUSCONTAINER_HPP
00018
00019 #include <iostream>
00020 #include <vector>
00021
00022 #include "torc/generic/om/PointerTypes.hpp"
00023 #include "torc/generic/util/Error.hpp"
00024
00025 namespace torc { namespace generic { class Status; } }
00026
00027 namespace torc {
00028
00029 namespace generic {
00030
00031
00032
00033
00034
00035
00036 class StatusContainer
00037 {
00038 public:
00039
00040
00041
00042
00043
00044 inline void
00045 getStatuses(std::vector< StatusSharedPtr > & outStatus) const throw();
00046
00047
00048
00049
00050
00051
00052 void
00053 setStatuses(const std::vector< StatusSharedPtr > & inStatus) throw();
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 void
00064 addStatus(const StatusSharedPtr & inStatus) throw(Error);
00065
00066
00067
00068
00069
00070
00071 template<typename _Action>
00072 inline void
00073 applyOnAllStatuses( const _Action &action ) throw(Error);
00074
00075 ~StatusContainer() throw();
00076
00077 protected:
00078 StatusContainer();
00079
00080 private:
00081 StatusContainer(const StatusContainer & source) throw();
00082
00083 StatusContainer & operator=(const StatusContainer & source) throw();
00084
00085 std::vector< StatusSharedPtr > mStatuses;
00086
00087 };
00088
00089
00090
00091
00092
00093 inline void
00094 StatusContainer::getStatuses(std::vector< StatusSharedPtr > & outStatus) const throw() {
00095 outStatus.insert( outStatus.end(),
00096 mStatuses.begin(), mStatuses.end() );
00097 }
00098
00099
00100
00101
00102
00103
00104 template<typename _Action>
00105 inline void
00106 StatusContainer::applyOnAllStatuses( const _Action &action ) throw(Error) {
00107 try
00108 {
00109 std::vector< StatusSharedPtr >::iterator it = mStatuses.begin();
00110 for(; it != mStatuses.end(); ++ it )
00111 {
00112 action( *it );
00113 }
00114 }
00115 catch(Error &e)
00116 {
00117 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00118 throw;
00119 }
00120 }
00121
00122 }
00123
00124 }
00125 #endif // TORC_GENERIC_OM_STATUSCONTAINER_HPP