Skip to content

Commit

Permalink
Cleanup all NULL->nullptr for great justice!
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Dec 16, 2016
1 parent df3f5da commit c52cff2
Show file tree
Hide file tree
Showing 24 changed files with 93 additions and 91 deletions.
2 changes: 1 addition & 1 deletion include/lsst/jointcal/AstromFit.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public :
//! Compute derivatives of measurement terms for this CcdImage
void LSDerivatives1(const CcdImage &ccdImage,
TripletList &tList, Eigen::VectorXd &rhs,
const MeasuredStarList *msList = NULL) const;
const MeasuredStarList *msList = nullptr) const;

//! Compute derivatives of reference terms (if any), associated to the FittedStarList
void LSDerivatives2(const FittedStarList & fsl, TripletList &tList, Eigen::VectorXd &rhs) const;
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/jointcal/BaseStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ double flux;

virtual ~BaseStar(){};

virtual std::string WriteHeader_(std::ostream & stream = std::cout, const char*i = NULL) const ;
virtual std::string WriteHeader_(std::ostream & stream = std::cout, const char*i = nullptr) const ;

virtual void WriteHeader(std::ostream & stream = std::cout) const;

Expand Down
4 changes: 2 additions & 2 deletions include/lsst/jointcal/FastFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public :

//! Find the closest with some rejection capability
const BaseStar *FindClosest(const Point &Where, const double MaxDist,
bool (*SkipIt)(const BaseStar *) = NULL) const;
bool (*SkipIt)(const BaseStar *) = nullptr) const;

//!
const BaseStar *SecondClosest(const Point &Where,
const double MaxDist,
const BaseStar* &Closest,
bool (*SkipIt)(const BaseStar *)= NULL) const;
bool (*SkipIt)(const BaseStar *)= nullptr) const;


//! mostly for debugging
Expand Down
8 changes: 4 additions & 4 deletions include/lsst/jointcal/FittedStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class FittedStar : public BaseStar, public PmBlock {
public:
FittedStar() :
BaseStar(), mag(-1), emag(-1), col(0.), gen(-1), wmag(0),
indexInMatrix(-1), measurementCount(0), refStar(NULL),
indexInMatrix(-1), measurementCount(0), refStar(nullptr),
flux2(-1),
fluxErr(-1),
fluxErr2(-1) {}

FittedStar(const BaseStar &B) :
BaseStar(B), mag(-1), emag(-1), col(0.), gen(-1), wmag(0),
indexInMatrix(0), measurementCount(0), refStar(NULL),
indexInMatrix(0), measurementCount(0), refStar(nullptr),
flux2(-1),
fluxErr(-1),
fluxErr2(-1) {}
Expand All @@ -87,7 +87,7 @@ class FittedStar : public BaseStar, public PmBlock {
{
indexInMatrix = -1;
measurementCount = 0;
refStar = NULL;
refStar = nullptr;
wmag = 0;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ class FittedStar : public BaseStar, public PmBlock {
double& FluxErr2() { return fluxErr2; }

//! write stuff
std::string WriteHeader_(std::ostream& pr=std::cout, const char* i=NULL) const;
std::string WriteHeader_(std::ostream& pr=std::cout, const char* i=nullptr) const;
virtual void writen(std::ostream& s) const;
virtual void read_it(std::istream& s, const char* format);
static BaseStar* read(std::istream& s, const char* format);
Expand Down
8 changes: 4 additions & 4 deletions include/lsst/jointcal/Gtransfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class GtransfoLinRot : public GtransfoLin {
using Gtransfo::apply; // to unhide apply(const Point&)

GtransfoLinRot() : GtransfoLin() {};
GtransfoLinRot(const double AngleRad, const Point *Center=NULL,
GtransfoLinRot(const double AngleRad, const Point *Center=nullptr,
const double ScaleFactor=1.0);
double fit(const StarMatchList &List);

Expand Down Expand Up @@ -463,7 +463,7 @@ public :
using Gtransfo::apply; // to unhide apply(const Point&)

BaseTanWcs(const GtransfoLin &Pix2Tan, const Point &TangentPoint,
const GtransfoPoly* Corrections = NULL);
const GtransfoPoly* Corrections = nullptr);

BaseTanWcs(const BaseTanWcs &Original);

Expand Down Expand Up @@ -507,7 +507,7 @@ class TanPix2RaDec : public BaseTanWcs {
using Gtransfo::apply; // to unhide apply(const Point&)
//! Pix2Tan describes the transfo from pix to tangent plane (in degrees). TangentPoint in degrees. Corrections are applied between Lin and deprojection parts (as in Swarp).
TanPix2RaDec(const GtransfoLin &Pix2Tan, const Point &TangentPoint,
const GtransfoPoly* Corrections = NULL);
const GtransfoPoly* Corrections = nullptr);


//! the transformation from pixels to tangent plane (coordinates in degrees)
Expand Down Expand Up @@ -551,7 +551,7 @@ class TanSipPix2RaDec : public BaseTanWcs

//! Pix2Tan describes the transfo from pix to tangent plane (in degrees). TangentPoint in degrees. Corrections are applied before Lin.
TanSipPix2RaDec(const GtransfoLin &Pix2Tan, const Point &TangentPoint,
const GtransfoPoly* Corrections = NULL);
const GtransfoPoly* Corrections = nullptr);


//! the transformation from pixels to tangent plane (coordinates in degrees)
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/jointcal/MeasuredStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MeasuredStar : public BaseStar
ccdImage(0),
valid(true) {}

MeasuredStar(const BaseStar &B, const FittedStar *F = NULL) :
MeasuredStar(const BaseStar &B, const FittedStar *F = nullptr) :
BaseStar(B),
mag(0.), wmag(0.), eflux(0.), aperrad(0.),
ccdImage(0),
Expand Down Expand Up @@ -85,7 +85,7 @@ class MeasuredStar : public BaseStar
// No longer decrement counter of associated fitted star in destructor (P. El-Hage le 10/04/2012)
// ~MeasuredStar() { if (fittedStar) fittedStar->MeasurementCount()--;}

std::string WriteHeader_(std::ostream & pr = std::cout, const char* i = NULL) const;
std::string WriteHeader_(std::ostream & pr = std::cout, const char* i = nullptr) const;
void writen(std::ostream& s) const;
static BaseStar* read(std::istream &s, const char* format);
};
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/jointcal/PhotomFit.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PhotomFit {
//! Compute the derivatives for this CcdImage. The last argument allows to to process a sub-list (used for outlier removal)
void LSDerivatives(const CcdImage &Ccd,
TripletList &TList, Eigen::VectorXd &Rhs,
const MeasuredStarList *M=NULL) const;
const MeasuredStarList *M=nullptr) const;

//! Set parameter groups fixed or variable and assign indices to each parameter in the big matrix (which will be used by OffsetParams(...).
void AssignIndices(const std::string &WhatToFit);
Expand Down
10 changes: 5 additions & 5 deletions include/lsst/jointcal/StarMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class StarMatchList : public std::list<StarMatch> {
//! enables to get a transformed StarMatchList. Only positions are transformed, not attached stars. const routine: "this" remains unchanged.
void ApplyTransfo(StarMatchList &Transformed,
const Gtransfo *PriorTransfo,
const Gtransfo *PosteriorTransfo = NULL) const;
const Gtransfo *PosteriorTransfo = nullptr) const;

/* constructor */
StarMatchList() : order(0), chi2(0){};
Expand All @@ -208,7 +208,7 @@ class StarMatchList : public std::list<StarMatch> {


//! returns the degree of freedom for the fit in x and y
int Dof(const Gtransfo *T=NULL) const;
int Dof(const Gtransfo *T=nullptr) const;

//! returns the order of the used transfo
int TransfoOrder() const {return order;}
Expand Down Expand Up @@ -254,12 +254,12 @@ class StarMatchList : public std::list<StarMatch> {
~StarMatchList() {/* should delete the transfo.... or use counted refs*/ };

//!: without descriptor for l2tup
void write_wnoheader(std::ostream & pr=std::cout, const Gtransfo *T=NULL ) const ;
void write_wnoheader(std::ostream & pr=std::cout, const Gtransfo *T=nullptr ) const ;


//! write StarMatchList with a header which can be read by l2tup
void write(const std::string &filename, const Gtransfo *tf=NULL) const;
void write(std::ostream &pr, const Gtransfo *tf=NULL) const;
void write(const std::string &filename, const Gtransfo *tf=nullptr) const;
void write(std::ostream &pr, const Gtransfo *tf=nullptr) const;


//! enables to dump a match std::list through : std::cout << List;
Expand Down
4 changes: 2 additions & 2 deletions src/Associations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void Associations::AssociateRefStars(double MatchCutInArcSec, const Gtransfo* T)
// clear previous associations if any :
for (RefStarIterator i = refStarList.begin(); i != refStarList.end(); ++i)
{
(*i)->SetFittedStar((FittedStar *) NULL );
(*i)->SetFittedStar(nullptr);
}

std::cout << " AssociateRefStars : MatchCutInArcSec " << MatchCutInArcSec << std::endl;
Expand Down Expand Up @@ -621,7 +621,7 @@ void Associations::AssociatePhotometricRefStars(double MatchCutInArcSec)
RefStarIterator I;
for (I = photRefStarList.begin(); I != photRefStarList.end(); I++)
{
(*I)->SetFittedStar( *(FittedStar*)NULL ); // mais c'est horrible (!)
(*I)->SetFittedStar(nullptr); // mais c'est horrible (!)
// cout << " XTP,YTP=" << (*I)->x << " " << (*I)->y << endl;
}

Expand Down
4 changes: 2 additions & 2 deletions src/AstroUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void readusno(const std::string &filebase,double minra,double maxra,
char line[80];
int idx[96],len[96],i,raidx0,pos;
float junk;
FILE *ifp=NULL;
FILE *ifp=nullptr;
unsigned int raword,decword,magword;
unsigned int minraword,maxraword,mindecword,maxdecword;
double mag;
Expand Down Expand Up @@ -355,7 +355,7 @@ int UsnoRead(double minra, double maxra,
double mindec, double maxdec, UsnoColor Color,
BaseStarList &ApmList)
{
const char *ascii_source = NULL;
const char *ascii_source = nullptr;

const char *env_var = getenv("USNOFILE");
if (env_var) ascii_source = env_var;
Expand Down
14 changes: 7 additions & 7 deletions src/AstromFit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CholmodSupernodalLLT2 : public Eigen::CholmodBase<_MatrixType, _UpLo, Chol
cholmod_sparse *C_cs_perm = cholmod_submatrix(C_cs,
Base::m_cholmodFactor->Perm,
Base::m_cholmodFactor->n,
NULL, -1, NULL, true, true,
nullptr, -1, nullptr, true, true,
&this->cholmod());

int ret = cholmod_updown(UpOrDown, &C_cs_perm, Base::m_cholmodFactor, &this->cholmod());
Expand Down Expand Up @@ -110,7 +110,7 @@ class CholmodSimplicialLDLT2 : public Eigen::CholmodBase<_MatrixType, _UpLo, Cho
cholmod_sparse *C_cs_perm = cholmod_submatrix(&C_cs,
(int *) Base::m_cholmodFactor->Perm,
Base::m_cholmodFactor->n,
NULL, -1, true, true,
nullptr, -1, true, true,
&this->cholmod());
assert(C_cs_perm);
int ret = cholmod_updown(UpOrDown, C_cs_perm, Base::m_cholmodFactor, &this->cholmod());
Expand Down Expand Up @@ -414,7 +414,7 @@ void AstromFit::LSDerivatives2(const FittedStarList &fsl, TripletList &tList, Ei
{
const FittedStar &fs = **i;
const RefStar *rs = fs.GetRefStar();
if (rs == NULL) continue;
if (rs == nullptr) continue;
proj.SetTangentPoint(fs);
// fs projects to (0,0), no need to compute its transform.
FatPoint rsProj;
Expand Down Expand Up @@ -576,7 +576,7 @@ void AstromFit::AccumulateStatRefStars(Accum &accum) const
{
FittedStar &fs = **i;
const RefStar *rs = fs.GetRefStar();
if (rs == NULL) continue;
if (rs == nullptr) continue;
proj.SetTangentPoint(fs);
// fs projects to (0,0), no need to compute its transform.
FatPoint rsProj;
Expand Down Expand Up @@ -749,7 +749,7 @@ unsigned AstromFit::FindOutliers(double nSigCut,
is; we use for that the type of the star attached to
the Chi2Entry. */
MeasuredStar *ms = dynamic_cast<MeasuredStar *>(i->ps);
FittedStar *fs = NULL;
FittedStar *fs = nullptr;
if (!ms) // it is reference term.
{
fs = dynamic_cast<FittedStar *>(i->ps);
Expand Down Expand Up @@ -808,7 +808,7 @@ void AstromFit::RemoveRefOutliers(FittedStarList &outliers)
for (auto i = outliers.begin(); i != outliers.end() ; ++i)
{
FittedStar &fs = **i;
fs.SetRefStar(NULL);
fs.SetRefStar(nullptr);
}
}

Expand Down Expand Up @@ -1215,7 +1215,7 @@ void AstromFit::MakeRefResTuple(const std::string &tupleName) const
{
const FittedStar &fs = **i;
const RefStar *rs = fs.GetRefStar();
if (rs == NULL) continue;
if (rs == nullptr) continue;
proj.SetTangentPoint(fs);
// fs projects to (0,0), no need to compute its transform.
FatPoint rsProj;
Expand Down
2 changes: 1 addition & 1 deletion src/BaseStar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BaseStar* BaseStar::read(std::istream & rd, const char *format)

std::string BaseStar::WriteHeader_(std::ostream & stream, const char*i) const
{
if (i==NULL) i = "";
if (i==nullptr) i = "";
stream << "# x"<< i <<" : x position (pixels)" << std::endl
<< "# y"<< i <<" : y position (pixels)" << std::endl
<< "# sx"<< i <<" : x position r.m.s " << std::endl
Expand Down
20 changes: 13 additions & 7 deletions src/ConstrainedPolyModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ reference exposure, expect troubles" << std::endl;
const Mapping* ConstrainedPolyModel::GetMapping(const CcdImage &C) const
{
mappingMapType::const_iterator i = _mappings.find(&C);
if (i==_mappings.end()) return NULL;
if (i==_mappings.end()) return nullptr;
return (i->second.get());
}

Expand Down Expand Up @@ -204,8 +204,11 @@ void ConstrainedPolyModel::FreezeErrorScales()
const Gtransfo& ConstrainedPolyModel::GetChipTransfo(const unsigned Chip) const
{
auto chipp = _chipMap.find(Chip);
if (chipp == _chipMap.end())
return *static_cast<const Gtransfo*>(NULL);// return 0, basically
if (chipp == _chipMap.end()) {
std::stringstream errMsg;
errMsg << "No such chipId: '" << Chip << "' found in chipMap of: " << this;
throw pexExcept::InvalidParameterError(errMsg.str());
}
return chipp->second->Transfo();
}

Expand All @@ -222,22 +225,25 @@ std::vector<ShootIdType> ConstrainedPolyModel::GetShoots() const
const Gtransfo& ConstrainedPolyModel::GetShootTransfo(const ShootIdType &Shoot) const
{
auto shootp = _shootMap.find(Shoot);
if (shootp == _shootMap.end())
return *static_cast<const Gtransfo*>(NULL); // return 0, basically
if (shootp == _shootMap.end()) {
std::stringstream errMsg;
errMsg << "No such shootId: '" << Shoot << "' found in shootMap of: " << this;
throw pexExcept::InvalidParameterError(errMsg.str());
}
return shootp->second->Transfo();
}


PTR(TanSipPix2RaDec) ConstrainedPolyModel::ProduceSipWcs(const CcdImage &Ccd) const
{
mappingMapType::const_iterator i = _mappings.find(&Ccd);
if (i==_mappings.end()) return NULL;
if (i==_mappings.end()) return nullptr;
const TwoTransfoMapping *m = i->second.get();

const GtransfoPoly &t1=dynamic_cast<const GtransfoPoly&>(m->T1());
const GtransfoPoly &t2=dynamic_cast<const GtransfoPoly&>(m->T2());
const TanRaDec2Pix *proj=dynamic_cast<const TanRaDec2Pix*>(Sky2TP(Ccd));
if (!(&t1) || !(&t2) || !proj) return NULL;
if (!(&t1) || !(&t2) || !proj) return nullptr;

GtransfoPoly pix2Tp = t2*t1;

Expand Down
22 changes: 11 additions & 11 deletions src/FastFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ const BaseStar *FastFinder::FindClosest(const Point &Where,
const double MaxDist,
bool (*SkipIt)(const BaseStar *)) const
{
if (count == 0) return NULL;
if (count == 0) return nullptr;
FastFinder::Iterator it = begin_scan(Where, MaxDist);
if (*it == NULL) return NULL;
const BaseStar *pbest = NULL;
if (*it == nullptr) return nullptr;
const BaseStar *pbest = nullptr;
double minDist2 = MaxDist*MaxDist;
for ( ; *it != NULL ; ++it)
for ( ; *it != nullptr ; ++it)
{
const BaseStar *p = *it;
if (SkipIt && SkipIt(p)) continue;
Expand All @@ -86,15 +86,15 @@ const BaseStar *FastFinder::SecondClosest(const Point &Where,
const BaseStar* &Closest,
bool (*SkipIt)(const BaseStar *)) const
{
Closest=NULL;
if (count == 0) return NULL;
Closest=nullptr;
if (count == 0) return nullptr;
FastFinder::Iterator it = begin_scan(Where, MaxDist);
if (*it == NULL) return NULL;
const BaseStar *pbest1 = NULL; // closest
const BaseStar *pbest2 = NULL; // second closest
if (*it == nullptr) return nullptr;
const BaseStar *pbest1 = nullptr; // closest
const BaseStar *pbest2 = nullptr; // second closest
double minDist1_2 = MaxDist*MaxDist;
double minDist2_2 = MaxDist*MaxDist;
for ( ; *it != NULL ; ++it)
for ( ; *it != nullptr ; ++it)
{
const BaseStar *p = *it;
if (SkipIt && SkipIt(p)) continue;
Expand Down Expand Up @@ -218,7 +218,7 @@ Iterator::Iterator(const FastFinder &F, const Point &Where,
FastFinder::stars_element Iterator::operator*() const
{
if (current!=null_value) return *current;
return NULL;
return nullptr;
}

void Iterator::operator++()
Expand Down

0 comments on commit c52cff2

Please sign in to comment.