Article
· Aug 17, 2017 1m read

How to determine if a class is mapped (e.g. from CACHELIB)

Here's one way to determine if a class is mapped (i.e. it is in a package whose definitions come from a database other than the default code database for the current namespace):

SAMPLES>w ##class(%Library.RoutineMgr).IsMapped("Cinema.Film.cls")
0
SAMPLES>w ##class(%Library.RoutineMgr).IsMapped("%iKnow.Objects.Source.cls")
1
SAMPLES>

If you pass a by-ref second argument to IsMapped you can also discover what database the class definition is stored in:

SAMPLES>w ##class(%Library.RoutineMgr).IsMapped("%iKnow.Objects.Source.cls",.db)
1
SAMPLES>w db
^^c:\intersystems\ens171\mgr\cachelib\
SAMPLES>

If you're nervous about using %Library.RoutineMgr because of the documentation warning:

This class is used internally by Caché. You should not make direct use of it within your applications. There is no guarantee made about either the behavior or future operation of this class.

then you can achieve the same thing using %SYS.Namespace as follows:

set isMapped=(##class(%SYS.Namespace).GetGlobalDest(,"oddDEF","%iKnow.Objects.Source")=##class(%SYS.Namespace).GetGlobalDest(,"oddDEF"))
Discussion (0)2
Log in or sign up to continue