Overview

The RoseDesignSection class holds objects within a RoseDesign in a manner that roughly corresponds to the sections of Part 21 files. Each design contains several sections that allow us to separate a the contents into data objects, header objects, and system objects. The RoseCursor class understands and can traverse the sections.

The RoseDesignSection class contains a few operations that can be used by applications. Refer to Design Sections for more information.

RoseDesignSection Constructor

RoseDesignSection (
	RoseDesign * owner, 
	RoseDesignSectionType typ = ROSE_SECTION_DATA
	);

Creating a design section automatically registers it with the owner design. By default, the new section is a data section, but an optional type parameter can be specified to create system or header sections.

The RoseDesign::dflt_section(), header_section(), and system_section() functions create sections if needed. The only time an application should need to create a section is when working with multiple data section Part 21 files.

ap_context()

RoseAPContext * ap_context();

void ap_context(
	RoseAPContext * new_context
	);

The ap_conform() functions set or return the application protocol context for a section. The context is used to indicate what schema a section is associated with when multiple data section files are used.

design()

RoseDesign * design();

void design(
	RoseDesign * new_owner
	);

The design() function gets and sets owner of a design section. A design section must always have an owner, but sections may be moved between designs by giving them a new owner. Moving sections while traversing a design with a cursor is permitted.

The following code moves all of the data sections from d1 to d2. Since we are traversing a linked list, we must cache the next() pointer since, after the move, it will no longer refer to a section in the original design.

RoseDesign * d1
RoseDesign * d2
RoseDesignSection * section = d1-> sections();
RoseDesignSection * next_section;

while (section) {
    next_section = section-> next();  /* cache value */
    if (section->section_type() == ROSE_SECTION_DATA)
	section-> design(d2);   /* move section */
    section = next_section;
}

is_data_type()

int is_data_type();

The is_data_type() function returns true if the section is a data section. This is equivalent to testing if section_type() is ROSE_SECTION_DATA.

RoseDesign * d;
RoseDesignSection * ds;

for (ds=d->sections(); ds; ds=ds->next()) {
    if (!ds-> is_data_type()) continue;
    /* do some sort of processing */
}

See Also

RoseDesignSectionType; RoseDesignSection::section_type()

is_header_type()

int is_header_type();

The is_header_type() function returns true if the section is a header section. This is equivalent to testing if section_type() is ROSE_SECTION_HEADER.

See Also

is_data_type()

is_system_type()

int is_system_type();

The is_system_type() function returns true if the section is a system section. This is equivalent to testing if section_type() is ROSE_SECTION_SYSTEM.

See Also

is_data_type()

name()

const char * name();

void name(
	const char * new_name
	);

The name() function sets and returns the name of a section. The name appears as an identifier in Part 21 files with multiple data sections.

next()

RoseDesignSection * next();

The sections of a design are kept in a linked list. The next() function returns the next section in that list. The function returns null when the section is the last in the list. The first section in the list can be found with the RoseDesign::sections() function.

previous()

RoseDesignSection * previous();

The sections of a design are kept in a linked list. The previous() function returns the previous section in that list. The function returns null when the section is the first in the list. The first section in the list can be found with the RoseDesign::sections() function.

section_type()

RoseDesignSectionType section_type();

void section_type(
	RoseDesignSectionType typ
	);

The section_type() function returns the design that owns a section. The second version is used to change the owner of a section.

RoseDesign * design;
char * type_name;

switch (design->dflt_section()->section_type()) {
case ROSE_SECTION_DATA:   type_name = data;   break;
case ROSE_SECTION_HEADER: type_name = header;   break;
case ROSE_SECTION_SYSTEM: type_name = system;   break;
default: 
    type_name = unknown;
}
printf (The default section is a %s section\n,
	type_name);

See Also

RoseDesignSectionType

size()

unsigned size();

The size() function returns the number of objects in a design section.

RoseDesign * design;
printf (There are %d system objects in design %s\n,
	design-> system_section()-> size(),
	design-> name());