28 #include <unordered_map> 75 extern "C" void sinkToOstream(
const char *text) {
76 auto osptr =
reinterpret_cast<std::ostream *
>(astChannelData);
83 auto thisStr = this->
show(
false);
84 auto rhsStr = rhs.
show(
false);
85 return rhsStr == thisStr;
91 {
"ChebyMap", makeShim<ChebyMap, AstChebyMap>},
92 {
"CmpFrame", makeShim<CmpFrame, AstCmpFrame>},
93 {
"Frame", makeShim<Frame, AstFrame>},
94 {
"FrameSet", makeShim<FrameSet, AstFrameSet>},
95 {
"FrameDict", makeShim<FrameDict, AstFrameSet>},
96 {
"KeyMap", makeShim<KeyMap, AstKeyMap>},
97 {
"LutMap", makeShim<LutMap, AstLutMap>},
98 {
"MathMap", makeShim<MathMap, AstMathMap>},
99 {
"MatrixMap", makeShim<MatrixMap, AstMatrixMap>},
100 {
"NormMap", makeShim<NormMap, AstNormMap>},
101 {
"ParallelMap", makeShim<ParallelMap, AstCmpMap>},
102 {
"PcdMap", makeShim<PcdMap, AstPcdMap>},
103 {
"PermMap", makeShim<PermMap, AstPermMap>},
104 {
"PolyMap", makeShim<PolyMap, AstPolyMap>},
105 {
"RateMap", makeShim<RateMap, AstRateMap>},
106 {
"SeriesMap", makeShim<SeriesMap, AstCmpMap>},
107 {
"ShiftMap", makeShim<ShiftMap, AstShiftMap>},
108 {
"SkyFrame", makeShim<SkyFrame, AstSkyFrame>},
109 {
"SlaMap", makeShim<SlaMap, AstSlaMap>},
110 {
"SpecFrame", makeShim<SpecFrame, AstSpecFrame>},
111 {
"SphMap", makeShim<SphMap, AstSphMap>},
112 {
"TimeFrame", makeShim<TimeFrame, AstTimeFrame>},
113 {
"TimeMap", makeShim<TimeMap, AstTimeMap>},
114 {
"TranMap", makeShim<TranMap, AstTranMap>},
115 {
"UnitMap", makeShim<UnitMap, AstUnitMap>},
116 {
"UnitNormMap", makeShim<UnitNormMap, AstUnitNormMap>},
117 {
"WcsMap", makeShim<WcsMap, AstWcsMap>},
118 {
"WinMap", makeShim<WinMap, AstWinMap>},
119 {
"ZoomMap", makeShim<ZoomMap, AstZoomMap>},
123 auto name_caster = ClassCasterMap.find(className);
124 if (name_caster == ClassCasterMap.end()) {
128 return name_caster->second(rawObj);
131 template <
typename Class>
133 AstObject *rawObjCopy = rawObj;
135 rawObjCopy =
reinterpret_cast<AstObject *
>(astCopy(rawObj));
141 auto retObjectBeforeCast = Object::_basicFromAstObject(rawObjCopy);
145 os <<
"The component is of type " << retObject->getClassName()
146 <<
", which could not be cast to the desired type " <<
typeid(Class).
name();
154 Channel ch(stream, showComments ?
"" :
"Comment=0");
161 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.