Back to index

nordugrid-arc-nox  1.1.0~rc6
DataStatus.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_DATASTATUS_H__
00004 #define __ARC_DATASTATUS_H__
00005 
00006 #include <iostream>
00007 #include <string>
00008 
00009 namespace Arc {
00010   
00011 #define DataStatusRetryableBase (100)
00012 
00016   class DataStatus {
00017 
00018   public:
00019 
00020     enum DataStatusType {
00021 
00023       Success = 0,
00024 
00026       ReadAcquireError = 1,
00027       ReadAcquireErrorRetryable = DataStatusRetryableBase+ReadAcquireError,
00028 
00030       WriteAcquireError = 2,
00031       WriteAcquireErrorRetryable = DataStatusRetryableBase+WriteAcquireError,
00032 
00034       ReadResolveError = 3,
00035       ReadResolveErrorRetryable = DataStatusRetryableBase+ReadResolveError,
00036 
00038       WriteResolveError = 4,
00039       WriteResolveErrorRetryable = DataStatusRetryableBase+WriteResolveError,
00040 
00042       ReadStartError = 5,
00043       ReadStartErrorRetryable = DataStatusRetryableBase+ReadStartError,
00044 
00046       WriteStartError = 6,
00047       WriteStartErrorRetryable = DataStatusRetryableBase+WriteStartError,
00048 
00050       ReadError = 7,
00051       ReadErrorRetryable = DataStatusRetryableBase+ReadError,
00052 
00054       WriteError = 8,
00055       WriteErrorRetryable = DataStatusRetryableBase+WriteError,
00056 
00058       TransferError = 9,
00059       TransferErrorRetryable = DataStatusRetryableBase+TransferError,
00060 
00062       ReadStopError = 10,
00063       ReadStopErrorRetryable = DataStatusRetryableBase+ReadStopError,
00064 
00066       WriteStopError = 11,
00067       WriteStopErrorRetryable = DataStatusRetryableBase+WriteStopError,
00068 
00070       PreRegisterError = 12,
00071       PreRegisterErrorRetryable = DataStatusRetryableBase+PreRegisterError,
00072 
00074       PostRegisterError = 13,
00075       PostRegisterErrorRetryable = DataStatusRetryableBase+PostRegisterError,
00076 
00078       UnregisterError = 14,
00079       UnregisterErrorRetryable = DataStatusRetryableBase+UnregisterError,
00080 
00082       CacheError = 15,
00083       CacheErrorRetryable = DataStatusRetryableBase+CacheError,
00084 
00086       CredentialsExpiredError = 16,
00087 
00089       DeleteError = 17,
00090       DeleteErrorRetryable = DataStatusRetryableBase+DeleteError,
00091 
00093       NoLocationError = 18,
00094 
00096       LocationAlreadyExistsError = 19,
00097 
00099       NotSupportedForDirectDataPointsError = 20,
00100 
00102       UnimplementedError = 21,
00103 
00105       IsReadingError = 22,
00106 
00108       IsWritingError = 23,
00109 
00111       CheckError = 24,
00112       CheckErrorRetryable = DataStatusRetryableBase+CheckError,
00113 
00115       ListError = 25,
00116       ListErrorRetryable = DataStatusRetryableBase+ListError,
00117 
00119       NotInitializedError = 26,
00120 
00122       SystemError = 27,
00123     
00125       StageError = 28,
00126       StageErrorRetryable = DataStatusRetryableBase+StageError,
00127       
00129       InconsistentMetadataError = 29,
00130  
00132       UnknownError = 30
00133     };
00134 
00135     DataStatus(const DataStatusType& status, std::string desc="")
00136       : status(status), desc(desc) {}
00137     DataStatus()
00138       : status(Success), desc("") {}
00139     ~DataStatus() {}
00140 
00141     bool operator==(const DataStatusType& s) {
00142       return status == s;
00143     }
00144     bool operator==(const DataStatus& s) {
00145       return status == s.status;
00146     }
00147   
00148     bool operator!=(const DataStatusType& s) {
00149       return status != s;
00150     }
00151     bool operator!=(const DataStatus& s) {
00152       return status != s.status;
00153     }
00154   
00155     DataStatus operator=(const DataStatusType& s) {
00156       status = s;
00157       return *this;
00158     }
00159 
00160     bool operator!() {
00161       return status != Success;
00162     }
00163     operator bool() {
00164       return status == Success;
00165     }
00166 
00167     bool Passed(void) {
00168       return (status == Success) || (status == NotSupportedForDirectDataPointsError);
00169     }
00170   
00171     bool Retryable() {
00172       return status > 100;
00173     }
00174   
00175     void SetDesc(std::string d) {
00176       desc = d;
00177     }
00178     
00179     std::string GetDesc() {
00180       return desc;
00181     }
00182 
00183     operator std::string(void) const;
00184 
00185   private:
00186   
00188     DataStatusType status;
00190     std::string desc;
00191 
00192   };
00193 
00194   inline std::ostream& operator<<(std::ostream& o, const DataStatus& d) {
00195     return (o << ((std::string)d));
00196   }
00197 } // namespace Arc
00198 
00199 
00200 #endif // __ARC_DATASTATUS_H__