Skip to content

Commit 28d20d7

Browse files
author
Nicholas Reed
committed
Cleanup in clstepcore. SCL git 239ce49 and f9b9383.
1 parent 1ed73e8 commit 28d20d7

24 files changed

Lines changed: 589 additions & 1011 deletions

src/clstepcore/ExpDict.cc

Lines changed: 137 additions & 294 deletions
Large diffs are not rendered by default.

src/clstepcore/ExpDict.inline.cc

Lines changed: 24 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,10 @@ TypeDescriptor::TypeDescriptor
206206
const char * d )
207207
: _name( nm ), altNames( 0 ), _fundamentalType( ft ),
208208
_originatingSchema( origSchema ), _referentType( 0 ), _description( d ),
209-
_where_rules( 0 )
210-
211-
{
209+
_where_rules( 0 ) {
212210
}
213211

214-
const char *
215-
TypeDescriptor::Name( const char * schnm ) const
216-
/*
212+
/**
217213
* Determines the current name of this. Normally, this is simply _name.
218214
* If "schnm" is set to a value, however, then this function becomes a
219215
* request for our name when referenced by schnm. (This will be diff from
@@ -223,7 +219,7 @@ TypeDescriptor::Name( const char * schnm ) const
223219
* and returns the new name if found. (See header comments to function
224220
* SchRename::rename().)
225221
*/
226-
{
222+
const char * TypeDescriptor::Name( const char * schnm ) const {
227223
if( schnm == NULL ) {
228224
return _name;
229225
}
@@ -235,13 +231,11 @@ TypeDescriptor::Name( const char * schnm ) const
235231
return _name;
236232
}
237233

238-
const char *
239-
TypeDescriptor::BaseTypeName() const {
234+
const char * TypeDescriptor::BaseTypeName() const {
240235
return BaseTypeDescriptor() ? BaseTypeDescriptor() -> Name() : 0;
241236
}
242237

243-
const TypeDescriptor *
244-
TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const {
238+
const TypeDescriptor * TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const {
245239
switch( NonRefType() ) {
246240
case AGGREGATE_TYPE:
247241
return AggrElemTypeDescriptor() -> IsA( td );
@@ -250,20 +244,17 @@ TypeDescriptor::BaseTypeIsA( const TypeDescriptor * td ) const {
250244
default:
251245
return IsA( td );
252246
}
253-
254247
}
255248

256-
int
257-
TypeDescriptor::CurrName( const char * other, const char * schNm ) const
258-
/*
249+
/**
259250
* Check if our "current" name = other. CurrName may be different from
260251
* _name if schNm tells us the current schema is a different one from the
261252
* one in which we're defined. If so, we may have an alternate name for
262253
* that schema (it may be listed in our altNames list). This would be the
263254
* case if schNm USEs or REFERENCEs type and renames it in the process
264255
* (e.g., "USE (X as Y)".
265256
*/
266-
{
257+
int TypeDescriptor::CurrName( const char * other, const char * schNm ) const {
267258
if( !schNm || *schNm == '\0' ) {
268259
// If there's no current schema, accept any possible name of this.
269260
// (I.e., accept its actual name or any substitute):
@@ -280,35 +271,29 @@ TypeDescriptor::CurrName( const char * other, const char * schNm ) const
280271
}
281272
}
282273

283-
int
284-
TypeDescriptor::PossName( const char * nm ) const
285-
/*
286-
* return TRUE if nm is either our name or one of the possible alternates.
274+
/**
275+
* return true if nm is either our name or one of the possible alternates.
287276
*/
288-
{
277+
int TypeDescriptor::PossName( const char * nm ) const {
289278
return ( OurName( nm ) || AltName( nm ) );
290279
}
291280

292-
int
293-
TypeDescriptor::OurName( const char * nm ) const {
281+
int TypeDescriptor::OurName( const char * nm ) const {
294282
return !StrCmpIns( nm, _name );
295283
}
296284

297-
int
298-
TypeDescriptor::AltName( const char * nm ) const {
285+
int TypeDescriptor::AltName( const char * nm ) const {
299286
if( altNames ) {
300287
return ( altNames->choice( nm ) );
301288
}
302289
return 0;
303290
}
304291

305-
void
306-
TypeDescriptor::addAltName( const char * schnm, const char * newnm )
307-
/*
292+
/**
308293
* Creates a SchRename consisting of schnm & newnm. Places it in alphabe-
309294
* tical order in this's altNames list.
310295
*/
311-
{
296+
void TypeDescriptor::addAltName( const char * schnm, const char * newnm ) {
312297
SchRename * newpair = new SchRename( schnm, newnm ),
313298
*node = ( SchRename * )altNames, *prev = NULL;
314299

@@ -327,13 +312,11 @@ TypeDescriptor::addAltName( const char * schnm, const char * newnm )
327312
}
328313
}
329314

330-
int
331-
SchRename::choice( const char * nm ) const
332-
/*
315+
/**
333316
* See if nm = one of our choices (either ours or that of a SchRename
334317
* later in the list.
335318
*/
336-
{
319+
int SchRename::choice( const char * nm ) const {
337320
if( !StrCmpIns( nm, newName ) ) {
338321
return 1;
339322
}
@@ -343,16 +326,14 @@ SchRename::choice( const char * nm ) const
343326
return 0;
344327
}
345328

346-
char *
347-
SchRename::rename( const char * schnm, char * newnm ) const
348-
/*
329+
/**
349330
* Check if this SchRename represents the rename of its owning TypeDesc for
350331
* schema schnm. (This will be the case if schnm = schName.) If so, the
351332
* new name is returned and copied into newnm. If not, ::rename is called
352333
* on next. Thus, this function will tell us if this or any later SchRe-
353334
* name in this list provide a new name for TypeDesc for schema schnm.
354335
*/
355-
{
336+
char * SchRename::rename( const char * schnm, char * newnm ) const {
356337
if( !StrCmpIns( schnm, schName ) ) {
357338
strcpy( newnm, newName );
358339
return newnm;
@@ -367,19 +348,11 @@ SchRename::rename( const char * schnm, char * newnm ) const
367348
// AttrDescriptor functions
368349
///////////////////////////////////////////////////////////////////////////////
369350

370-
AttrDescriptor::AttrDescriptor(
371-
const char * name, // i.e. char *
372-
const TypeDescriptor * domainType,
373-
Logical optional, // i.e. F U or T
374-
Logical unique, // i.e. F U or T
375-
AttrType_Enum at, // AttrType_Explicit,AttrType_Inverse,
376-
// AttrType_Deriving,AttrType_Redefining
377-
const EntityDescriptor & owner )
351+
AttrDescriptor::AttrDescriptor( const char * name, const TypeDescriptor * domainType,
352+
Logical optional, Logical unique, AttrType_Enum at,
353+
const EntityDescriptor & owner )
378354
: _name( name ), _domainType( domainType ), _optional( optional ),
379-
_unique( unique ), _attrType( at ),
380-
381-
_owner( ( EntityDescriptor & )owner )
382-
{
355+
_unique( unique ), _attrType( at ), _owner( ( EntityDescriptor & )owner ) {
383356
}
384357

385358
AttrDescriptor::~AttrDescriptor() {
@@ -413,47 +386,8 @@ Logical AttrDescriptor::Deriving() const {
413386
return LFalse;
414387
}
415388

416-
/*
417-
// outdated function
418-
void
419-
AttrDescriptor::Derived( SDAI_LOGICAL x ) {
420-
if( x.asInt() ) {
421-
_attrType = AttrType_Deriving;
422-
} else {
423-
_attrType = AttrType_Explicit;
424-
}
425-
}
426-
*/
427-
428-
// outdated function
429-
void
430-
AttrDescriptor::Derived( Logical x ) {
431-
if( x == LTrue ) {
432-
_attrType = AttrType_Deriving;
433-
} else {
434-
_attrType = AttrType_Explicit;
435-
}
436-
}
437-
438-
// outdated function
439-
void
440-
AttrDescriptor::Derived( const char * x ) {
441-
if( !strcmp( x, "LTrue" ) || !strcmp( x, "T" ) ) {
442-
_attrType = AttrType_Deriving;
443-
} else {
444-
_attrType = AttrType_Explicit;
445-
}
446-
}
447-
448-
449-
Derived_attribute::Derived_attribute(
450-
const char * name, // i.e. char *
451-
const TypeDescriptor * domainType,
452-
Logical optional, // i.e. F U or T
453-
Logical unique, // i.e. F U or T
454-
AttrType_Enum at, // AttrType_Explicit,AttrType_Inverse,
455-
// AttrType_Deriving,AttrType_Redefining
456-
const EntityDescriptor & owner )
389+
Derived_attribute::Derived_attribute( const char * name, const TypeDescriptor * domainType,
390+
Logical optional, Logical unique, AttrType_Enum at, const EntityDescriptor & owner )
457391
: AttrDescriptor( name, domainType, optional, unique, at, owner ) {
458392
_initializer = ( const char * )0;
459393
}

src/clstepcore/Registry.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
* and is not subject to copyright.
1313
*/
1414

15-
/* $Id: Registry.h,v 3.0.1.7 1997/11/05 21:59:19 sauderd DP3.1 $ */
16-
1715
#include <sdai.h>
18-
//#include <STEPentity.h>
1916
#include <errordesc.h>
2017
#include <scl_hash.h>
2118
#include <Str.h>

src/clstepcore/Registry.inline.cc

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ static int uniqueNames( const char *, const SchRename * );
2424

2525
Registry::Registry( CF_init initFunct )
2626
: col( 0 ), entity_cnt( 0 ), all_ents_cnt( 0 ) {
27-
// if(NilSTEPentity == 0)
28-
// NilSTEPentity = new SDAI_Application_instance;
2927

30-
/* Registry tables aren't always initialized */
3128
primordialSwamp = HASHcreate( 1000 );
3229
active_schemas = HASHcreate( 10 );
3330
active_types = HASHcreate( 100 );
@@ -61,11 +58,9 @@ Registry::Registry( CF_init initFunct )
6158
0, // Originating Schema
6259
"Number" );
6360

64-
/* t_GENERIC_TYPE = new TypeDescriptor("GENERIC", GENERIC_TYPE, "Generic");*/
65-
6661
initFunct( *this );
6762
HASHlistinit( active_types, &cur_type );
68-
HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur\'s
63+
HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur's
6964
HASHlistinit( active_schemas, &cur_schema );
7065
}
7166

@@ -92,8 +87,7 @@ void Registry::DeleteContents() {
9287
// types
9388
}
9489

95-
const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const
96-
/*
90+
/**
9791
* schNm refers to the current schema. This will have a value if we are
9892
* reading from a Part 21 file (using a STEPfile object), and the file
9993
* declares a schema name in the File_Schema section of the Header. (If
@@ -102,7 +96,7 @@ const EntityDescriptor * Registry::FindEntity( const char * e, const char * schN
10296
* entity A from schema Y and renames it to B, X should only refer to A as
10397
* B. Thus, if schNm here = "X", only e="B" would be valid but not e="A".
10498
*/
105-
{
99+
const EntityDescriptor * Registry::FindEntity( const char * e, const char * schNm, int check_case ) const {
106100
const EntityDescriptor * entd;
107101
const SchRename * altlist;
108102
char schformat[BUFSIZ], altName[BUFSIZ];
@@ -186,15 +180,14 @@ void Registry::AddType( const TypeDescriptor & d ) {
186180
HASHinsert( active_types, ( char * ) d.Name(), ( TypeDescriptor * ) &d );
187181
}
188182

189-
void Registry::AddClones( const EntityDescriptor & e )
190-
/*
183+
/**
191184
* Purpose is to insert e into the registry hashed according to all its
192185
* alternate names (the names it was renamed with when other schemas USEd
193186
* or REFERENCEd it). This will make these names available to the Registry
194187
* so that if we comes across one of them in a Part 21 file, we'll recog-
195188
* nize it.
196189
*/
197-
{
190+
void Registry::AddClones( const EntityDescriptor & e ) {
198191
const SchRename * alts = e.AltNameList();
199192

200193
while( alts ) {
@@ -205,15 +198,13 @@ void Registry::AddClones( const EntityDescriptor & e )
205198
all_ents_cnt += uniqueNames( e.Name(), e.AltNameList() );
206199
}
207200

208-
static int
209-
uniqueNames( const char * entnm, const SchRename * altlist )
210-
/*
201+
/**
211202
* Returns the number of unique names in an entity's _altname list. If
212203
* schema B uses ent xx from schema A and renames it to yy, and schema C
213204
* does the same (or if C simply uses yy from B), altlist will contain 2
214205
* entries with the same alt name.
215206
*/
216-
{
207+
static int uniqueNames( const char * entnm, const SchRename * altlist ) {
217208
int cnt = 0;
218209
const SchRename * alt = altlist;
219210

@@ -259,11 +250,10 @@ void Registry::RemoveType( const char * n ) {
259250
HASHsearch( active_types, &tmp, HASH_DELETE );
260251
}
261252

262-
void Registry::RemoveClones( const EntityDescriptor & e )
263-
/*
253+
/**
264254
* Remove all the "clones", or rename values of e.
265255
*/
266-
{
256+
void Registry::RemoveClones( const EntityDescriptor & e ) {
267257
const SchRename * alts = e.AltNameList();
268258
struct Element * tmp;
269259

@@ -276,11 +266,10 @@ void Registry::RemoveClones( const EntityDescriptor & e )
276266
}
277267

278268

279-
SDAI_Application_instance *
280-
Registry::ObjCreate( const char * nm, const char * schnm, int check_case ) const {
269+
SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * schnm, int check_case ) const {
281270
const EntityDescriptor * entd = FindEntity( nm, schnm, check_case );
282271
if( entd ) {
283-
SDAI_Application_instance *se =
272+
SDAI_Application_instance * se =
284273
( ( EntityDescriptor * )entd ) -> NewSTEPentity();
285274

286275
// See comment in previous function.

0 commit comments

Comments
 (0)