Working with entities, Listing all entities, Working with entities 2 – Apple Network Setup User Manual
Page 30: Listing all entities 2

C H A P T E R 2
Using Network Setup
30
Working with Entities
Working with Entities
2
Once you have a reference to the database and an area identifier for the default
area, the next step is to look for appropriate entities within that area. Regardless
of what you want to do to an entity, you must first obtain a reference to it. An
entity reference is an opaque data structure that Network Setup uses to
uniquely identify each entity within an area.
Typically there are two ways to get the entity reference for an entity within an
area.
■
You can list all of the entities of a particular class and type and display that
list to the user. For example, you might want to list all of the TCP/IP
network connection entities so that the user can choose the one to make
active. The section “Listing All Entities” (page 30) explains how to do this.
■
You can find the currently active entity of a particular class and type. This is
useful when you want to read the current network settings. The section
“Finding an Active Entity” (page 34) explains how to do this.
You can also create, duplicate, rename, and delete entities. These tasks are easy
to do and are not explained in detail in this chapter. See “Network Setup
Reference” (page 57) for information about
Listing All Entities
2
Listing 2-5 shows the routine
MyGetEntitiesList
, which generates a list of all of
the entities within an area of the database. The routine’s database reference and
area identifier parameters are obtained by opening the database, as explained in
“Opening the Database for Reading” (page 25). The
entityClass
and
entityType
parameters specify the entities to list. Some common scenarios include:
■
Getting all entities of a specific class and type. Set the
entityClass
and
entityType
parameters to that class and type. For example, to find all TCP/IP
network connection entities, supply a class of
kOTCfgClassNetworkConnection
and a type of
kOTCfgTypeTCPv4
. See “Entity Classes and Types” (page 104) for
a list of the defined classes and types.