28 #include <unordered_map> 78 extern "C" void sinkToOstream(
const char *text) {
79 auto osptr =
reinterpret_cast<std::ostream *
>(astChannelData);
86 auto thisStr = this->
show(
false);
87 auto rhsStr = rhs.
show(
false);
88 return rhsStr == thisStr;
94 {
"ChebyMap", makeShim<ChebyMap, AstChebyMap>},
95 {
"CmpFrame", makeShim<CmpFrame, AstCmpFrame>},
96 {
"FitsChan", makeShim<FitsChan, AstFitsChan>},
97 {
"FitsTable", makeShim<FitsTable, AstFitsTable>},
98 {
"Frame", makeShim<Frame, AstFrame>},
99 {
"FrameSet", makeShim<FrameSet, AstFrameSet>},
100 {
"FrameDict", makeShim<FrameDict, AstFrameSet>},
101 {
"KeyMap", makeShim<KeyMap, AstKeyMap>},
102 {
"LutMap", makeShim<LutMap, AstLutMap>},
103 {
"MathMap", makeShim<MathMap, AstMathMap>},
104 {
"MatrixMap", makeShim<MatrixMap, AstMatrixMap>},
105 {
"NormMap", makeShim<NormMap, AstNormMap>},
106 {
"ParallelMap", makeShim<ParallelMap, AstCmpMap>},
107 {
"PcdMap", makeShim<PcdMap, AstPcdMap>},
108 {
"PermMap", makeShim<PermMap, AstPermMap>},
109 {
"PolyMap", makeShim<PolyMap, AstPolyMap>},
110 {
"RateMap", makeShim<RateMap, AstRateMap>},
111 {
"SeriesMap", makeShim<SeriesMap, AstCmpMap>},
112 {
"ShiftMap", makeShim<ShiftMap, AstShiftMap>},
113 {
"SkyFrame", makeShim<SkyFrame, AstSkyFrame>},
114 {
"SlaMap", makeShim<SlaMap, AstSlaMap>},
115 {
"SpecFrame", makeShim<SpecFrame, AstSpecFrame>},
116 {
"SphMap", makeShim<SphMap, AstSphMap>},
117 {
"TimeFrame", makeShim<TimeFrame, AstTimeFrame>},
118 {
"Table", makeShim<Table, AstTable>},
119 {
"TimeMap", makeShim<TimeMap, AstTimeMap>},
120 {
"TranMap", makeShim<TranMap, AstTranMap>},
121 {
"UnitMap", makeShim<UnitMap, AstUnitMap>},
122 {
"UnitNormMap", makeShim<UnitNormMap, AstUnitNormMap>},
123 {
"WcsMap", makeShim<WcsMap, AstWcsMap>},
124 {
"WinMap", makeShim<WinMap, AstWinMap>},
125 {
"ZoomMap", makeShim<ZoomMap, AstZoomMap>},
129 auto name_caster = ClassCasterMap.find(className);
130 if (name_caster == ClassCasterMap.end()) {
134 return name_caster->second(rawObj);
137 template <
typename Class>
139 AstObject *rawObjCopy = rawObj;
141 rawObjCopy =
reinterpret_cast<AstObject *
>(astCopy(rawObj));
147 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
151 os <<
"The component is of type " << retObject->getClassName()
152 <<
", which could not be cast to the desired type " <<
typeid(Class).
name();
160 Channel ch(stream, showComments ?
"" :
"Comment=0");
167 show(os, showComments);
void annulAstObject(AstObject *object)
A wrapper around astAnnul; intended as a custom deleter for std::unique_ptr.
AST wrapper classes and functions.
Channel provides input/output of AST objects.
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Throw std::runtime_error if AST's state is bad.
std::shared_ptr< Object > copy() const
Return a deep copy of this object.
static std::shared_ptr< Class > fromAstObject(AstObject *rawObj, bool copy)
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type...
Object(Object const &object)
Copy constructor: make a deep copy.
int write(Object const &object)
Write an object to a channel.
T dynamic_pointer_cast(T... args)
std::string getClassName(AstObject const *rawObj)
Get the AST class name, changing CmpMap to SeriesMap or ParallelMap as appropriate.
void show(std::ostream &os, bool showComments=true) const
Print a textual description the object to an ostream.
Abstract base class for all AST objects.
bool operator==(Object const &rhs) const
Return True if this and rhs are the equal.
A stream for ast::Channel.