Introduction
Mako relies on an inheritance model, whereby classes are derived from a parent class. Consider this inheritance diagram from the API documentation:
Sometimes it's necessary to cast an object into a related type, to access member variables or methods that would otherwise be unavailable.
For example, here the developer needed to cast an IAnnotation to an ITextAnnotation, so that the Author string is available.
auto annots = page->getAnnotations();
for (uint8 i = 0; i < annots.size(); i++)
{
ITextAnnotationPtr textAnnot = obj2ITextAnnotation(annots[i]);
if (textAnnot && textAnnot->getAuthor() == "Arthur Smith")
...
}
var annots = page.getAnnotations().toVector();
foreach(var annot in annots)
{
var textAnnot = ITextAnnotation.fromRCObject(annot);
if (textAnnot != null)
{
if (textAnnot.getAuthor() == "Arthur Smith")
...
}
}
var annots = page.getAnnotations().toVector();
for(var annot : annots)
{
var textAnnot = ITextAnnotation.fromRCObject(annot);
if (textAnnot != null)
{
if (textAnnot.getAuthor() == "Arthur Smith")
...
}
}
for annot in annots:
text_annot: ITextAnnotation = ITextAnnotation.fromRCObject(annot)
if text_annot is not None and text_annot.getAuthor() == 'Arthur Smith':
...
If the cast fails, a null object is returned.
C#, Java and Python
These languages do not have the same inheritance model as C++, but the underlying Mako classes are the same as C++. For these, we have two methods that allow for the equivalent of a cast. They are fromRCObject() and toRCObject(). In the C# example above, toRCObject() is omitted, and can be in most cases, it simply provides a hint to the interpreter. The above example could also be written as shown here, and would work in the same way.
var textAnnot = ITextAnnotation.fromRCObject(annots[i].toRCObject());
C++
For C++, you can often rely on your IDE to suggest the right cast. Begin by typing 'edlobj2...' or 'obj2...'. However, the required header file may not be in scope; you can use the list below to find the cast you need, and the header file that defines it.
Classes from the EDL namespace (edlobj2)
|
Object |
Code |
Header File |
|---|---|---|
|
|
|
cmm.cpp |
|
|
|
domannotationappearance.h |
|
|
|
domannotationappearance.h |
|
|
|
domcatalog.h |
|
|
|
dompage.h |
|
|
|
domfontopentype.h |
|
|
|
domfontpcl.h |
|
|
|
domfontpcl.h |
|
|
|
domform.h |
|
|
|
domglyphs.h |
|
|
|
domjobtk.h |
|
|
|
domfonttruetype.h |
|
|
|
domoutline.h |
|
|
|
domoutline.h |
|
|
|
domannotationmanager.h |
|
|
|
dompath.h |
|
|
|
cedloutputfromencryptedmessage.h |
|
|
|
edlxpsgetpageevent.h |
|
|
|
gdcxpsmessages.h |
|
|
|
domfontpcl5.cpp |
|
|
|
cinputmemorystream.h |
|
|
|
pagecontentssizeavailable.h |
|
|
|
pdfmetadata.h |
|
|
|
cpsexec.h |
|
|
|
cpsexec.h |
|
|
|
pcl5_glyph.h |
|
|
|
icolormanager.h |
|
|
|
iimagecodec.h |
|
|
|
idom.h |
|
|
|
idomtarget.h |
|
|
|
idomtarget.h |
|
|
|
idomannotation.h |
|
|
|
idomannotationappearance.h |
|
|
|
idomannotationappearance.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idomannotation.h |
|
|
|
idompathgeometry.h |
|
|
|
idomresources.h |
|
|
|
idombrush.h |
|
|
|
idomcanvas.h |
|
|
|
idomcatalog.h |
|
|
|
idomcharpathgroup.h |
|
|
|
idomcolor.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomcolorspace.h |
|
|
|
idomimageresource.h |
|
|
|
idomcontent.h |
|
|
|
idomimageresource.h |
|
|
|
idomcolorspace.h |
|
|
|
idomdocs.h |
|
|
|
idomdocs.h |
|
|
|
idomfunction.h |
|
|
|
idomextattr.h |
|
|
|
idomextattr.h |
|
|
|
idomtarget.h |
|
|
|
idomimageresource.h |
|
|
|
idomdocs.h |
|
|
|
idompage.h |
|
|
|
idomfont.h |
|
|
|
idomfont.h |
|
|
|
idomfont.h |
|
|
|
idomfontpcl.h |
|
|
|
idomfontpcl.h |
|
|
|
idomfont.h |
|
|
|
idomfont.h |
|
|
|
idomfont.h |
|
|
|
idomfont.h |
|
|
|
idomform.h |
|
|
|
idomform.h |
|
|
|
domfragment.h |
|
|
|
idomfunction.h |
|
|
|
idomglyph.h |
|
|
|
idomglyphs.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomgroup.h |
|
|
|
idomfunction.h |
|
|
|
idomhashable.h |
|
|
|
idomresources.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idombrush.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idominputfilter.h |
|
|
|
idomtarget.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomjobtk.h |
|
|
|
idomimageresource.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomresources.h |
|
|
|
idommc.h |
|
|
|
idommetadata.h |
|
|
|
idomnode.h |
|
|
|
idomnoderel.h |
|
|
|
idomnoderel.h |
|
|
|
idombrush.h |
|
|
|
idomopt.h |
|
|
|
idomopt.h |
|
|
|
idomopt.h |
|
|
|
idomoutline.h |
|
|
|
idomoutline.h |
|
|
|
idomoutline.h |
|
|
|
idomoutline.h |
|
|
|
idomoutputfilter.h |
|
|
|
idomannotationmanager.h |
|
|
|
idomlinkmanager.h |
|
|
|
idomtarget.h |
|
|
|
idomtarget.h |
|
|
|
idompathgeometry.h |
|
|
|
idompathgeometry.h |
|
|
|
idompath.h |
|
|
|
idompathgeometry.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomsecurity.h |
|
|
|
idomimageresource.h |
|
|
|
idompathgeometry.h |
|
|
|
idompathgeometry.h |
|
|
|
idompathgeometry.h |
|
|
|
idomfunction.h |
|
|
|
idomresources.h |
|
|
|
idombrush.h |
|
|
|
idomresources.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
idomrefnode.h |
|
|
|
idomresources.h |
|
|
|
idomresources.h |
|
|
|
idomfunction.h |
|
|
|
idomsecurity.h |
|
|
|
idomiterator.h |
|
|
|
idomiterator.h |
|
|
|
idomiterator.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomshape.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomsecurity.h |
|
|
|
idomfunction.h |
|
|
|
idomtarget.h |
|
|
|
idomimageresource.h |
|
|
|
domfragment.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomgroup.h |
|
|
|
idomfont.h |
|
|
|
idombrush.h |
|
|
|
idombrush.h |
|
|
|
idomimageresource.h |
|
|
|
edlqname.h |
|
|
|
iedloutputfromencryptedsourcemessage.h |
|
|
|
edlstream.h |
|
|
|
iedltempstore.h |
|
|
|
edltime.h |
|
|
|
ifilespec.h |
|
|
|
ifilespec.h |
|
|
|
ifilespec.h |
|
|
|
ifilespec.h |
|
|
|
ifilter.h |
|
|
|
ifilter.h |
|
|
|
ifilterparams.h |
|
|
|
ifilter.h |
|
|
|
ifilterproperties.h |
|
|
|
idomfontpcl.h |
|
|
|
libfont.h |
|
|
|
idomfont.h |
|
|
|
idomfontpcl.h |
|
|
|
idomfontpcl.h |
|
|
|
idomfontpcl.h |
|
|
|
idomfont.h |
|
|
|
igenericfilter.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
edlstream.h |
|
|
|
isession.h |
|
|
|
isession.h |
|
|
|
ixpsin.h |
|
|
|
ixpsprovider.h |
|
|
|
ixpsprovider.h |
Objects without an EDL prefix (obj2)
|
Object |
Code |
Header File |
|---|---|---|
|
|
|
pdfobjects.h |
|
|
|
idomimageresource.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
pdfobjects.h |
|
|
|
pagelayout.cpp |
|
|
|
makofonts.cpp |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects-structure.cpp |
|
|
|
pdfobjects-structure.cpp |
|
|
|
pdfobjects-structure.cpp |
|
|
|
idomimageresource.h |
|
|
|
idomimageresource.h |
|
|
|
pdfobjects.h |
|
|
|
interactive.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
domdv.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
structure.h |
|
|
|
structure.h |
|
|
|
interactive.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
makofontspriv.h |
|
|
|
pcl5input.h |
|
|
|
pcl5output.h |
|
|
|
makofontspriv.h |
|
|
|
pclxlinput.h |
|
|
|
pclxloutput.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfinput.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfoutput.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
pjl.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
psinput.h |
|
|
|
psoutput.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
pdfobjects.h |
|
|
|
structure.h |
|
|
|
structure.h |
|
|
|
pdfobjects.h |
|
|
|
structure.h |
|
|
|
pdfobjects.h |
|
|
|
pdfobjects.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
interactive.h |
|
|
|
xpspackage.h |
|
|
|
xpspackage.h |
|
|
|
xpsinput.h |
|
|
|
xpsoutput.h |
|
|
|
idomimageresource.h |