Back to index

nordugrid-arc-nox  1.1.0~rc6
MCC_Status.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 // MCC_Status.cpp
00006 
00007 #include <arc/message/MCC_Status.h>
00008 
00009 namespace Arc {
00010 
00011   std::string string(StatusKind kind){
00012     if (kind==STATUS_UNDEFINED)
00013       return "STATUS_UNDEFINED";
00014     else if (kind==STATUS_OK)
00015       return "STATUS_OK";
00016     else if(kind==GENERIC_ERROR)
00017       return "GENERIC_ERROR";
00018     else if(kind==PARSING_ERROR)
00019       return "PARSING_ERROR";
00020     else if(kind==PROTOCOL_RECOGNIZED_ERROR)
00021       return "PROTOCOL_RECOGNIZED_ERROR";
00022     else if(kind==UNKNOWN_SERVICE_ERROR)
00023       return "UNKNOWN_SERVICE_ERROR";
00024     else if(kind==BUSY_ERROR)
00025       return "BUSY_ERROR";
00026     else  // There should be no other alternative!
00027       return "";
00028   }
00029 
00030   MCC_Status::MCC_Status(StatusKind kind,
00031                          const std::string& origin,
00032                          const std::string& explanation):
00033     kind(kind),
00034     origin(origin),
00035     explanation(explanation)
00036   {
00037   }
00038 
00039   bool MCC_Status::isOk() const{
00040     return kind==STATUS_OK;
00041   }
00042 
00043   StatusKind MCC_Status::getKind() const{
00044     return kind;
00045   }
00046 
00047   const std::string& MCC_Status::getOrigin() const{
00048     return origin;
00049   }
00050 
00051   const std::string& MCC_Status::getExplanation() const{
00052     return explanation;
00053   }
00054 
00055   MCC_Status::operator std::string() const{
00056     return origin + ": " + string(kind) + " (" + explanation + ")";
00057   }
00058 
00059 }