Top Up Prev Next Bottom Contents Index Search

10.2 Class KnownTarget

The KnownTarget class keeps track of targets in much the same way that KnownBlock keeps track of blocks. There are some differences: there is only a single list of targets, not one per domain as for blocks. The constructor works exactly the same way that the constructor for KnownBlock works; the code

static MyTarget proto(args); 
static KnownTarget entry(proto,"MyTarget");
adds the prototype instance to the known list with a call to addEntry.

static void addEntry (Target &target, const char* name, int onHeap); 
This function actually adds the Target to the list. If onHeap is true, the target will be destroyed when the entry is removed or replaced from the list. There is only one list of Targets.

static const Target* find (const char* name); 
The find method returns a pointer the appropriate target. A null pointer is returned if no match is found.

static Target* clone (const char* name); 
The clone method takes a string, finds the appropriate target on the known target list, and returns a clone of that target (the cloneTarget method is called on the target). This method, as a rule, generates a duplicate of the target. An error message is generated (with Error::abortRun) and a null pointer is returned if there is no match.

static int getList (const Block& b, const char** names, int nMax); 
This function returns a list of names of targets that are compatible with the Block b. The return value gives the number of matches. The names array can hold nMax strings; if there are more, only the first nMax are returned.

static int getList (const char* dom, const char** names, int nMax); 
This function is the same as above, except that it returns names of targets that are compatible with stars of a particular domain.

static int isDynamic (const char* type); 
Return true if there is a target on the known list named type that is dynamically linked; otherwise return false.

static const char* defaultName (const char* dom = 0); 
Return the default target name for a domain (default: current domain). There is an iterator associated with KnownTarget, called KnownTargetIter. Since there is only one known target list, it is unusual for an iterator in that it takes no argument for its constructor. Its next function returns the type const Target *; it steps through the targets on the known list.



Top Up Prev Next Bottom Contents Index Search

Copyright © 1990-1997, University of California. All rights reserved.