Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
ArcSec::PeriodAttribute Class Reference

Formate: *datetime"/"duration *datetime"/"datetime *duration"/"datetime. More...

#include <DateTimeAttribute.h>

Inheritance diagram for ArcSec::PeriodAttribute:
Inheritance graph
[legend]
Collaboration diagram for ArcSec::PeriodAttribute:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PeriodAttribute ()
 PeriodAttribute (const std::string &v, const std::string &i)
virtual ~PeriodAttribute ()
virtual bool equal (AttributeValue *other, bool check_id=true)
 Evluate whether "this" equale to the parameter value.
virtual std::string encode ()
 encode the value in a string format
ArcPeriod getValue ()
virtual std::string getType ()
 Get the DataType of the <Attribute>
virtual std::string getId ()
 Get the AttributeId of the <Attribute>

Static Public Member Functions

static const std::string & getIdentifier (void)

Private Attributes

ArcPeriod value
std::string id

Static Private Attributes

static std::string identifier = "period"

Detailed Description

Formate: *datetime"/"duration *datetime"/"datetime *duration"/"datetime.

Definition at line 127 of file DateTimeAttribute.h.


Constructor & Destructor Documentation

Definition at line 134 of file DateTimeAttribute.h.

{ };
ArcSec::PeriodAttribute::PeriodAttribute ( const std::string &  v,
const std::string &  i 
)

Definition at line 189 of file DateTimeAttribute.cpp.

                                                                      {
  id=i;
  (value.starttime).SetTime(-1);
  (value.endtime).SetTime(-1);
  (value.duration).SetPeriod(0);

  Arc::Time t1(-1), t2(-1);
  Arc::Period d1(0), d2(0);

  std::string::size_type pos = v.find("/");
  std::string s1 = v.substr(0, pos);
  std::string s2 = v.substr(pos+1);

  pos = s1.find("-");
  if(pos == std::string::npos) pos = s1.find(":");
  if(pos == std::string::npos) pos = s1.find("Z");
  if(pos == std::string::npos) pos = s1.find("GMT");
  if(pos != std::string::npos)
    t1 = Arc::Time(s1);
  else
    d1 = Arc::Period(s1);

  pos = s2.find("-");
  if(pos == std::string::npos) pos = s2.find(":");
  if(pos == std::string::npos) pos = s2.find("Z");
  if(pos == std::string::npos) pos = s2.find("GMT");
  if(pos != std::string::npos)
    t2 = Arc::Time(s2);
  else
    d2 = Arc::Period(s2);

  if(t1.GetTime()!=-1){
    if(t2.GetTime()!=-1){
      value.starttime = t1;
      value.endtime = t2;
    }
    else if(d2.GetPeriod()!=0){
      value.starttime = t1;
      value.duration = d2;
    }
    else {
      //std::cerr<<"Invalid ISO period format!"<<std::endl;
    }
  }
  else{
    if(d1.GetPeriod()!=0){
      if(t2.GetTime()!=-1){
        value.duration = d1;
        value.endtime = t2;
      }
      else {
        //std::cerr<<"Invalid ISO period format!"<<std::endl;
      }
    }
    else {
      //std::cerr<<"Invalid ISO period format!"<<std::endl;
    }
  }
}

Here is the call graph for this function:

virtual ArcSec::PeriodAttribute::~PeriodAttribute ( ) [inline, virtual]

Definition at line 136 of file DateTimeAttribute.h.

{ };

Member Function Documentation

std::string ArcSec::PeriodAttribute::encode ( ) [virtual]

encode the value in a string format

Implements ArcSec::AttributeValue.

Definition at line 292 of file DateTimeAttribute.cpp.

                                 {
  std::string s1 = (std::string)(value.starttime);
  std::string s2 = (std::string)(value.endtime);
  std::string s3 = (std::string)(value.duration);

  if(value.starttime==Arc::Time(-1))
    return(s3+"/"+s2);
  else if(value.endtime==Arc::Time(-1))
    return(s1+"/"+s3);
  else
    return(s1+"/"+s2);
}
bool ArcSec::PeriodAttribute::equal ( AttributeValue value,
bool  check_id = true 
) [virtual]

Evluate whether "this" equale to the parameter value.

Implements ArcSec::AttributeValue.

Definition at line 249 of file DateTimeAttribute.cpp.

                                                           {
  PeriodAttribute *other;
  try{
    other = dynamic_cast<PeriodAttribute*>(o);
  } catch(std::exception&) { };
  if(other==NULL){
    //std::cerr<<"not PeriodAttribute"<<std::endl;
    return false;
  }
  if(check_id) { if(id != other->id) return false; }
  
  ArcPeriod oth = other->getValue();
  Arc::Time ls, le, os, oe;
  Arc::Period ld, od;
  ls = value.starttime;
  le = value.endtime;
  os = oth.starttime;
  oe = oth.endtime;
  ld = value.duration;
  od = oth.duration;

  if((ls!=Arc::Time(-1))&&(le==Arc::Time(-1)))
    le = ls + ld;
  else if((ls==Arc::Time(-1))&&(le!=Arc::Time(-1)))
    ls = le - ld;
  else if((ls==Arc::Time(-1))||(le==Arc::Time(-1)))
    return false;

  if((os!=Arc::Time(-1))&&(oe==Arc::Time(-1)))
    oe = os + od;
  else if((os==Arc::Time(-1))&&(oe!=Arc::Time(-1)))
    os = oe - od;
  else if((os==Arc::Time(-1))||(oe==Arc::Time(-1)))
    return false;
  
  //std::cout<<ls.str()<<(std::string)(ld)<<os.str()<<(std::string)(od)<<std::endl;

  if((ls==os)&&(le==oe))
    return true;
  else 
    return false;
}

Here is the call graph for this function:

virtual std::string ArcSec::PeriodAttribute::getId ( ) [inline, virtual]

Get the AttributeId of the <Attribute>

Implements ArcSec::AttributeValue.

Definition at line 142 of file DateTimeAttribute.h.

{return id;};
static const std::string& ArcSec::PeriodAttribute::getIdentifier ( void  ) [inline, static]

Definition at line 143 of file DateTimeAttribute.h.

{ return identifier; };

Here is the caller graph for this function:

virtual std::string ArcSec::PeriodAttribute::getType ( ) [inline, virtual]

Get the DataType of the <Attribute>

Implements ArcSec::AttributeValue.

Definition at line 141 of file DateTimeAttribute.h.

{return identifier; };

Definition at line 140 of file DateTimeAttribute.h.

{ return value; };

Here is the caller graph for this function:


Member Data Documentation

std::string ArcSec::PeriodAttribute::id [private]

Definition at line 131 of file DateTimeAttribute.h.

std::string ArcSec::PeriodAttribute::identifier = "period" [static, private]

Definition at line 129 of file DateTimeAttribute.h.

Definition at line 130 of file DateTimeAttribute.h.


The documentation for this class was generated from the following files: