SAF_Set *
saf_declare_set(SAF_ParMode pmode, /* The parallel mode. */
SAF_Db *db, /* The database handle in which to create the set. */
const char *name, /* The name of the set being declared. */
int max_topo_dim, /* The topological dimension of the set. If the set will contain sets of different
* topological dimensions then this must be the maximum topological dimension of any
* set in the subset inclusion lattice rooted below SET. */
SAF_SilRole role, /* The role of the set. Possible values are SAF_SPACE for a spatial set, SAF_TIME for
* a time-base set, SAF_PARAM for a parameter space set, or SAF_USERD for a user-defined
* role. */
SAF_ExtendMode extmode, /* Indicates whether or not the base-space represented by the set is extendible. Possible
* values are SAF_EXTENDIBLE_TRUE or SAF_EXTENDIBLE_FALSE */
SAF_Set *set /* [OUT] Optional memory for link to the newly declared set. */
)
{
SAF_ENTER(saf_declare_set, NULL);
ss_scope_t scope=SS_SCOPE_NULL; /* Scope where the new set will be created. */
SAF_REQUIRE(_saf_valid_pmode(pmode), SAF_LOW_CHK_COST, NULL,
_saf_errmsg("PMODE must be valid"));
if (!_saf_is_participating_proc(pmode)) SAF_RETURN(NULL);
SAF_REQUIRE(SS_FILE(db), SAF_LOW_CHK_COST, NULL,
_saf_errmsg("DATABASE must be a valid handle"));
SAF_REQUIRE(name, SAF_LOW_CHK_COST, NULL,
_saf_errmsg("NAME cannot be NULL"));
SAF_REQUIRE(name[0] != '@', SAF_LOW_CHK_COST, NULL,
_saf_errmsg("NAME must not begin with a leading '@'"));
SAF_REQUIRE(max_topo_dim >= 0, SAF_LOW_CHK_COST, NULL,
_saf_errmsg("MAX_TOPO_DIM must be positive"));
SAF_REQUIRE(role == SAF_TIME || role == SAF_SPACE || role == SAF_PARAM || role == SAF_SUITE,
SAF_LOW_CHK_COST, NULL,
_saf_errmsg("ROLE must be SAF_TIME, SAF_SPACE, or SAF_PARAM"));
#ifdef SSLIB_SUPPORT_PENDING
/* So which is it: MAX_TOPO_DIM==1 or 0<=MAX_TOPO_DIM<=1? */
#endif
SAF_REQUIRE(role != SAF_TIME || (0 <= max_topo_dim && max_topo_dim <= 1),
SAF_LOW_CHK_COST, NULL,
_saf_errmsg("if ROLE is SAF_TIME then MAX_TOPO_DIM must be 1"));
SAF_REQUIRE(extmode != SAF_EXTENDIBLE_TORF, SAF_LOW_CHK_COST, NULL,
_saf_errmsg("EXTMODE must be either SAF_EXTENDIBLE_TRUE or SAF_EXTENDIBLE_FALSE"));
/* Build a set record. */
ss_file_topscope(db, &scope);
set = (ss_set_t*)ss_pers_new(&scope, SS_MAGIC(ss_set_t), NULL, SAF_ALL==pmode?SS_ALLSAME:0U, (ss_pers_t*)set, NULL);
if (!set)
SAF_ERROR(NULL,_saf_errmsg("unable to init set record"));
/* Fill in the set's modeling data. */
if (SAF_EACH==pmode) SS_PERS_UNIQUE(set);
ss_string_set(SS_SET_P(set,name), name);
SS_SET(set)->user_id = 0;
SS_SET(set)->tdim = max_topo_dim;
SS_SET(set)->srole = role;
SS_SET(set)->is_top = TRUE; /* a set is "always" considered a top at first */
SS_SET(set)->is_extendible = (hbool_t) extmode;
SAF_LEAVE(set);
}