#include <cassert>
#include "rrfactory.h"
CacheRRPtr RRFactory::NewCacheRR(RRType i_ty, RRClass i_cl, unsigned i_uTTL, const char *ci_strRData) {
CacheRRPtr crpOut = new CacheRR;
RDataPtr rdp;
crpOut->SetTTL(i_uTTL);
crpOut->SetType(i_ty);
crpOut->SetClass(i_cl);
rdp = RData::New(i_ty,i_cl);
rdp->SetRData(ci_strRData);
crpOut->SetRData(rdp);
return crpOut;
}
CacheRRPtr RRFactory::NewCacheRR(RRType i_ty, RRClass i_cl, unsigned i_uTTL, RDataPtr &i_rdp) {
CacheRRPtr crpOut = new CacheRR;
crpOut->SetTTL(i_uTTL);
crpOut->SetType(i_ty);
crpOut->SetClass(i_cl);
crpOut->SetRData(i_rdp);
return crpOut;
}
CacheRRPtr RRFactory::NewCacheRR(RRConstPtr ci_rrp) {
CacheRRPtr crpOut = new CacheRR;
RDataPtr rdp;
crpOut->SetTTL(ci_rrp->GetTTL());
crpOut->SetType(ci_rrp->GetType());
crpOut->SetClass(ci_rrp->GetClass());
rdp = ci_rrp->GetRData()->Clone();
crpOut->SetRData(rdp);
return crpOut;
}
RRPtr RRFactory::NewRR(LabelListPtr &i_llprName, RRType i_ty, RRClass i_cl, unsigned i_uTTL, RDataPtr &i_rdpr) {
RRPtr rrpOut;
rrpOut = new RR;
rrpOut->SetName(i_llprName);
i_llprName = NULL;
rrpOut->SetTTL(i_uTTL);
rrpOut->SetType(i_ty);
rrpOut->SetClass(i_cl);
rrpOut->SetRData(i_rdpr);
i_rdpr = NULL;
return rrpOut;
}
RRPtr RRFactory::NewRR(LabelListPtr &i_llrpName, CacheRRConstPtr ci_crp) {
RRPtr rrpOut = new RR;
RDataPtr rdp;
rrpOut->SetName(i_llrpName);
rrpOut->SetTTL(ci_crp->GetTTL());
rrpOut->SetType(ci_crp->GetType());
rrpOut->SetClass(ci_crp->GetClass());
rdp = ci_crp->GetRData()->Clone();
rrpOut->SetRData(rdp);
return rrpOut;
}
RRPtr RRFactory::NewRR(RRConstPtr ci_rrp) {
RRPtr rrpOut = new RR;
LabelListPtr llp;
RDataPtr rdp;
llp = new LabelList(*ci_rrp->GetName());
rrpOut->SetName(llp);
rrpOut->SetTTL(ci_rrp->GetTTL());
rrpOut->SetType(ci_rrp->GetType());
rrpOut->SetClass(ci_rrp->GetClass());
rdp = ci_rrp->GetRData()->Clone();
rrpOut->SetRData(rdp);
return rrpOut;
}