Back to index

nordugrid-arc-nox  1.1.0~rc6
DateTimeAttribute.h
Go to the documentation of this file.
00001 #ifndef __ARC_SEC_DATETIMEATTRIBUTE_H__
00002 #define __ARC_SEC_DATETIMEATTRIBUTE_H__
00003 
00004 #include <arc/security/ArcPDP/attr/AttributeValue.h>
00005 #include <arc/DateTime.h>
00006 
00007 namespace ArcSec {
00008 //DateTimeAttribute, TimeAttribute, DateAttribute, DurationAttribute, PeriodAttribute
00009 //As reference: See  Date and Time on the Internet: Timestamps 
00010 //(http://www.ietf.org/rfc/rfc3339.txt)
00011 
00012 //DateTimeAttribute
00020 class DateTimeAttribute : public AttributeValue {
00021 private:
00022   static std::string identifier;
00023   Arc::Time value; //using the Time class definition in DateTime.h
00024   std::string id;
00025 
00026 public:
00027   DateTimeAttribute(){ };
00028   DateTimeAttribute(const std::string& v,const std::string& i) : value(v), id(i) {};
00029   virtual ~DateTimeAttribute(){ };
00030 
00031   virtual bool equal(AttributeValue* other, bool check_id = true);
00032   virtual bool lessthan(AttributeValue* other);
00033   virtual bool inrange(AttributeValue* other);
00034   virtual std::string encode(); //encode value into ISOTime format
00035   Arc::Time getValue(){ return value; };
00036   virtual std::string getType() {return identifier; };
00037   virtual std::string getId() {return id;};
00038   static const std::string& getIdentifier(void) { return identifier; };
00039 };
00040 
00041 //TimeAttribute
00048 class TimeAttribute : public AttributeValue {
00049 private:
00050   static std::string identifier;
00051   Arc::Time value;
00052   std::string id;
00053 
00054 public:
00055   TimeAttribute() { };
00056   TimeAttribute(const std::string& v,const std::string& i);
00057   virtual ~TimeAttribute(){ };
00058 
00059   virtual bool equal(AttributeValue* other, bool check_id = true);
00060   virtual bool lessthan(AttributeValue* other);
00061   virtual std::string encode();
00062   Arc::Time getValue(){ return value; };
00063   virtual std::string getType() {return identifier; };
00064   virtual std::string getId() {return id;};
00065   static const std::string& getIdentifier(void) { return identifier; };
00066 };
00067 
00068 //DateAttribute
00069 //Formate: 
00070 //YYYY-MM-DD
00071 class DateAttribute : public AttributeValue {
00072 private:
00073   static std::string identifier;
00074   Arc::Time value;
00075   std::string id;
00076 
00077 public:
00078   DateAttribute() { };
00079   DateAttribute(const std::string& v,const std::string& i);
00080   virtual ~DateAttribute(){ };
00081 
00082   virtual bool equal(AttributeValue* other, bool check_id = true);
00083   virtual bool lessthan(AttributeValue* other);
00084   virtual std::string encode();
00085   Arc::Time getValue(){ return value; };
00086   virtual std::string getType() {return identifier; };
00087   virtual std::string getId() {return id;};
00088   static const std::string& getIdentifier(void) { return identifier; };
00089 };
00090 
00091 
00092 //DurationAttribute
00096 class DurationAttribute : public AttributeValue {
00097 private:
00098   static std::string identifier;
00099   Arc::Period value;
00100   std::string id;
00101 
00102 public:
00103   DurationAttribute() { };
00104   DurationAttribute(const std::string& v,const std::string& i) : value(v), id(i){};
00105   virtual ~DurationAttribute(){ };
00106 
00107   virtual bool equal(AttributeValue* other, bool check_id = true);
00108   virtual std::string encode();
00109   Arc::Period getValue(){ return value; };
00110   virtual std::string getType() {return identifier;};
00111   virtual std::string getId() {return id;};
00112   static const std::string& getIdentifier(void) { return identifier; };
00113 };
00114 
00115 typedef struct{
00116   Arc::Time starttime;
00117   Arc::Time endtime;
00118   Arc::Period duration;
00119 }ArcPeriod;
00120 
00121 //PeriodAttribute
00127 class PeriodAttribute : public AttributeValue {
00128 private:
00129   static std::string identifier;
00130   ArcPeriod value;
00131   std::string id;
00132 
00133 public:
00134   PeriodAttribute() { };
00135   PeriodAttribute(const std::string& v,const std::string& i);
00136   virtual ~PeriodAttribute(){ };
00137 
00138   virtual bool equal(AttributeValue* other, bool check_id = true);
00139   virtual std::string encode();
00140   ArcPeriod getValue(){ return value; };
00141   virtual std::string getType() {return identifier; };
00142   virtual std::string getId() {return id;};
00143   static const std::string& getIdentifier(void) { return identifier; };
00144 };
00145 
00146 }// namespace ArcSec
00147 
00148 #endif /* __ARC_SEC_DATETIMEATTRIBUTE_H__ */
00149