Back to index

nordugrid-arc-nox  1.1.0~rc6
FileInfo.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_FILEINFO_H__
00004 #define __ARC_FILEINFO_H__
00005 
00006 #include <list>
00007 #include <string>
00008 
00009 #include <arc/DateTime.h>
00010 #include <arc/URL.h>
00011 
00012 namespace Arc {
00013 
00015   class FileInfo {
00016 
00017   public:
00018 
00019     enum Type {
00020       file_type_unknown = 0,
00021       file_type_file = 1,
00022       file_type_dir = 2
00023     };
00024 
00025     FileInfo(const std::string& name = "")
00026       : name(name),
00027         size((unsigned long long int)(-1)),
00028         created((time_t)(-1)),
00029         valid((time_t)(-1)),
00030         type(file_type_unknown),
00031         latency("") {}
00032 
00033     ~FileInfo() {}
00034 
00035     const std::string& GetName() const {
00036       return name;
00037     }
00038 
00039     std::string GetLastName() const {
00040       std::string::size_type pos = name.rfind('/');
00041       if (pos != std::string::npos)
00042         return name.substr(pos + 1);
00043       else
00044         return name;
00045     }
00046 
00047     const std::list<URL>& GetURLs() const {
00048       return urls;
00049     }
00050 
00051     void AddURL(const URL& u) {
00052       urls.push_back(u);
00053     }
00054 
00055     bool CheckSize() const {
00056       return (size != (unsigned long long int)(-1));
00057     }
00058 
00059     unsigned long long int GetSize() const {
00060       return size;
00061     }
00062 
00063     void SetSize(const unsigned long long int s) {
00064       size = s;
00065     }
00066 
00067     bool CheckCheckSum() const {
00068       return (!checksum.empty());
00069     }
00070 
00071     const std::string& GetCheckSum() const {
00072       return checksum;
00073     }
00074 
00075     void SetCheckSum(const std::string& c) {
00076       checksum = c;
00077     }
00078 
00079     bool CheckCreated() const {
00080       return (created != -1);
00081     }
00082 
00083     Time GetCreated() const {
00084       return created;
00085     }
00086 
00087     void SetCreated(const Time& t) {
00088       created = t;
00089     }
00090 
00091     bool CheckValid() const {
00092       return (valid != -1);
00093     }
00094 
00095     Time GetValid() const {
00096       return valid;
00097     }
00098 
00099     void SetValid(const Time& t) {
00100       valid = t;
00101     }
00102 
00103     bool CheckType() const {
00104       return (type != file_type_unknown);
00105     }
00106 
00107     Type GetType() const {
00108       return type;
00109     }
00110 
00111     void SetType(const Type t) {
00112       type = t;
00113     }
00114 
00115     bool CheckLatency() const {
00116       return (!latency.empty());
00117     }
00118 
00119     std::string GetLatency() const {
00120       return latency;
00121     }
00122 
00123     void SetLatency(const std::string l) {
00124       latency = l;
00125     }
00126 
00127     std::map<std::string, std::string> GetMetaData() const {
00128       return metadata;
00129     }
00130     
00131     void SetMetaData(const std::string att, const std::string val) {
00132       metadata[att] = val;
00133     }
00134     
00135   private:
00136 
00137     std::string name;
00138     std::list<URL> urls;         // Physical enpoints/URLs.
00139     unsigned long long int size; // Size of file in bytes.
00140     std::string checksum;        // Checksum of file.
00141     Time created;                // Creation/modification time.
00142     Time valid;                  // Valid till time.
00143     Type type;                   // File type - usually file_type_file
00144     std::string latency;         // Access latenct of file (applies to SRM only)
00145     std::map<std::string, std::string> metadata; // Generic metadata attribute-value pairs
00146   };
00147 
00148 } // namespace Arc
00149 
00150 #endif // __ARC_FILEINFO_H__