Commits
32 32 | |
33 33 | |
34 34 | |
35 35 | using namespace std; |
36 36 | using namespace casacore; |
37 37 | using namespace casa; |
38 38 | |
39 39 | using namespace casacore; |
40 40 | namespace casac { |
41 41 | |
42 - | quanta::quanta() |
42 + | quanta::quanta(): itsLog(new LogIO()) |
43 43 | { |
44 - | itsLog = new LogIO(); |
45 44 | UnitMap::putUser("pix",UnitVal(1.0), "pixel units"); |
46 45 | } |
47 46 | |
48 47 | quanta::~quanta() |
49 48 | { |
50 - | |
51 49 | } |
52 50 | |
53 51 | casacore::QuantumHolder |
54 52 | quanta::quantumHolderFromVar(const ::casac::variant& theVar){ |
55 53 | casacore::QuantumHolder qh; |
56 54 | try { |
57 55 | String error; |
58 56 | if(theVar.type()== ::casac::variant::STRING ) { |
59 57 | if(!qh.fromString(error, theVar.toString())) { |
60 58 | *itsLog << LogIO::SEVERE << "Error " << error |
65 63 | *itsLog << LogIO::WARN << "Only first vector element will be used." |
66 64 | << LogIO::POST; |
67 65 | // if(!qh.fromString(error, theVar.toStringVec()[0])) { |
68 66 | if(!qh.fromString(error, theVar.toString())) { |
69 67 | *itsLog << LogIO::SEVERE << "Error " << error |
70 68 | << " in converting quantity "<< LogIO::POST; |
71 69 | } |
72 70 | } |
73 71 | if(theVar.type()== ::casac::variant::RECORD){ |
74 72 | ::casac::variant localvar(theVar); |
75 - | Record * ptrRec = toRecord(localvar.asRecord()); |
73 + | std::unique_ptr<Record> ptrRec(toRecord(localvar.asRecord())); |
76 74 | if(!qh.fromRecord(error, *ptrRec)){ |
77 75 | *itsLog << LogIO::SEVERE << "Error " << error |
78 76 | << " in converting quantity "<< LogIO::POST; |
79 77 | } |
80 - | delete ptrRec; |
81 78 | } |
82 79 | } catch (AipsError x) { |
83 80 | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
84 81 | << LogIO::POST; |
85 82 | RETHROW(x); |
86 83 | } |
87 84 | return qh; |
88 85 | } |
89 86 | |
90 87 | casac::record* |
823 820 | casacore::QuantumHolder qh; |
824 821 | String error; |
825 822 | if(v.type()== ::casac::variant::STRING || |
826 823 | v.type()== ::casac::variant::STRINGVEC){ |
827 824 | if(qh.fromString(error, v.toString())){ |
828 825 | retval=qh.isQuantity(); |
829 826 | } |
830 827 | } |
831 828 | if(v.type()== ::casac::variant::RECORD){ |
832 829 | ::casac::variant localvar(v); |
833 - | Record * ptrRec = toRecord(localvar.asRecord()); |
830 + | std::unique_ptr<Record> ptrRec(toRecord(localvar.asRecord())); |
834 831 | if(qh.fromRecord(error, *ptrRec)){ |
835 832 | retval=(qh.isQuantity() || qh.isQuantumArrayDouble()); |
836 833 | } |
837 - | delete ptrRec; |
838 834 | } |
839 835 | } catch (AipsError x) { |
840 836 | *itsLog << LogIO::SEVERE << "Exception Reported: " << x.getMesg() |
841 837 | << LogIO::POST; |
842 838 | RETHROW(x); |
843 839 | } |
844 840 | return retval; |
845 841 | } |
846 842 | |
847 843 | |