Skip to content

Commit e48330b

Browse files
committed
remove c++11 code and HAVE_JUDY macro
1 parent a41d44d commit e48330b

File tree

10 files changed

+12
-150
lines changed

10 files changed

+12
-150
lines changed

data/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
9393
add_dependencies( lazy_${PROJECT_NAME} version_string )
9494
set_target_properties( p21read_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
9595
${${PROJECT_NAME}_COMPILE_FLAGS} )
96-
set_target_properties( lazy_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -DHAVE_JUDY -I${SCL_SOURCE_DIR}/src/base/judy/src" )
96+
set_target_properties( lazy_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${SCL_SOURCE_DIR}/src/base/judy/src" )
9797

9898

9999
#add user-defined executables

src/cllazyfile/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ include_directories(
1414
../base/judy/src
1515
)
1616

17-
add_definitions( -DHAVE_JUDY -DNO_REGISTRY )
1817
SCL_ADDLIB(steplazyfile "${clLazyFile_SRCS} ${clLazyFile_HDRS}" "stepcore stepdai steputils base")
1918
scl_addexec(lazy_test "lazy_test.cc" "steplazyfile stepeditor" )
20-
set_target_properties(steplazyfile lazy_test PROPERTIES COMPILE_FLAGS "-std=c++11" )
19+
set_target_properties(lazy_test PROPERTIES COMPILE_FLAGS "-DNO_REGISTRY" )

src/cllazyfile/headerSectionReader.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,9 @@ class headerSectionReader: public sectionReader {
2727
}
2828

2929
~headerSectionReader() {
30-
#ifdef HAVE_JUDY
3130
//FIXME delete each instance?! maybe add to clear, since it iterates over everything already
3231
//enum clearHow { rawData, deletePointers }
3332
_headerInstances->clear();
34-
#else //HAVE_JUDY
35-
int i = 0;
36-
instancesLoaded_t::iterator it = _headerInstances.begin();
37-
for( ; it != _headerInstances.end(); it++ ) {
38-
delete it->second;
39-
i++;
40-
}
41-
std::cerr << "deleted " << i << " header instances" << std::endl;
42-
#endif //HAVE_JUDY
4333
}
4434
};
4535

src/cllazyfile/lazyInstMgr.cc

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <unordered_map>
21
#include "lazyTypes.h"
32
#include "lazyInstMgr.h"
43
#include "Registry.h"
@@ -27,17 +26,8 @@ lazyInstMgr::~lazyInstMgr() {
2726
for( ; sit != _dataSections.end(); sit++ ) {
2827
delete *sit;
2928
}
30-
#ifdef HAVE_JUDY
3129
_instancesLoaded.clear();
3230
_instanceStreamPos.clear();
33-
#else //HAVE_JUDY
34-
int i = 0;
35-
instancesLoaded_t::iterator it = _instancesLoaded.begin();
36-
for( ; it != _instancesLoaded.end(); it++ ) {
37-
delete it->second;
38-
i++;
39-
}
40-
#endif //HAVE_JUDY
4131
}
4232

4333
sectionID lazyInstMgr::registerDataSection( lazyDataSectionReader * sreader ) {
@@ -53,7 +43,6 @@ void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) {
5343
_longestTypeNameLen = len;
5444
_longestTypeName = inst.name;
5545
}
56-
#ifdef HAVE_JUDY
5746
_instanceTypes->insert( inst.name, inst.loc.instance );
5847
/* store 16 bits of section id and 48 of instance offset into one 64-bit int
5948
* TODO: check and warn if anything is lost (in calling code?)
@@ -68,38 +57,19 @@ void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) {
6857
if( inst.refs->size() > 0 ) {
6958
//forward refs
7059
_fwdInstanceRefs.insert( inst.loc.instance, *inst.refs );
71-
auto it = inst.refs->cbegin();
72-
for( ; it != inst.refs->cend(); it++ ) {
60+
instanceRefs::iterator it = inst.refs->begin();
61+
for( ; it != inst.refs->end(); it++ ) {
7362
//reverse refs
7463
_revInstanceRefs.insert( *it, inst.loc.instance );
7564
}
7665
} else {
7766
delete inst.refs;
7867
}
7968
}
80-
#else // HAVE_JUDY
81-
_instanceTypes->insert( instanceTypes_pair( inst.name, inst.loc.instance ) );
82-
_instanceStreamPos.insert( instanceStreamPos_pair( inst.loc.instance, inst.loc ) );
83-
if( inst.refs->size() > 0 ) {
84-
//forward refs
85-
_fwdInstanceRefs.insert( instanceRefs_pair( inst.loc.instance, inst.refs ) );
86-
auto it = inst.refs->cbegin();
87-
for( ; it != inst.refs->cend(); it++ ) {
88-
//reverse refs
89-
if( _revInstanceRefs.find( *it ) == _revInstanceRefs.end() ) {
90-
_revInstanceRefs.insert( instanceRefs_pair( *it, new std::set< instanceID > ) );
91-
}
92-
_revInstanceRefs[ *it ]->insert( inst.loc.instance );
93-
}
94-
} else {
95-
delete inst.refs;
96-
}
97-
#endif // HAVE_JUDY
9869
}
9970

10071
unsigned long lazyInstMgr::getNumTypes() const {
10172
unsigned long n = 0 ;
102-
#ifdef HAVE_JUDY
10373
instanceTypes_t::cpair curr, end;
10474
end = _instanceTypes->end();
10575
curr = _instanceTypes->begin();
@@ -110,13 +80,6 @@ unsigned long lazyInstMgr::getNumTypes() const {
11080
curr = _instanceTypes->next();
11181
}
11282
}
113-
#else // HAVE_JUDY
114-
// http://www.daniweb.com/software-development/cpp/threads/384836/multimap-and-counting-number-of-keys#post1657899
115-
auto iter = _instanceTypes->cbegin();
116-
for( ; iter != _instanceTypes->cend(); iter = _instanceTypes->equal_range( iter->first ).second ) {
117-
++n;
118-
}
119-
#endif // HAVE_JUDY
12083
return n ;
12184
}
12285

src/cllazyfile/lazyInstMgr.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class lazyInstMgr {
7373
return _ima;
7474
}
7575

76-
#ifdef HAVE_JUDY
7776
instanceRefs_t * getFwdRefs() {
7877
return & _fwdInstanceRefs;
7978
}
@@ -93,29 +92,6 @@ class lazyInstMgr {
9392
}
9493
return v->size();
9594
}
96-
#else //HAVE_JUDY
97-
instanceRefs_range getFwdRefs() {
98-
instanceRefs_range r;
99-
r.first = _fwdInstanceRefs.cbegin();
100-
r.second = _fwdInstanceRefs.cend();
101-
return r;
102-
}
103-
104-
instanceRefs_range getRevRefs() {
105-
instanceRefs_range r;
106-
r.first = _revInstanceRefs.cbegin();
107-
r.second = _revInstanceRefs.cend();
108-
return r;
109-
}
110-
/// returns two iterators delimiting the instances that match `type`
111-
instanceTypes_range getInstances( std::string type ) const {
112-
return _instanceTypes->equal_range( type );
113-
}
114-
/// get the number of instances of a certain type
115-
unsigned int countInstances( std::string type ) {
116-
return _instanceTypes->count( type );
117-
}
118-
#endif //HAVE_JUDY
11995
instancesLoaded_t * getHeaderInstances( fileID file ) {
12096
return _files[file]->getHeaderInstances();
12197
}

src/cllazyfile/lazyTypes.h

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
#include <vector>
66
#include <stdint.h>
77

8-
#ifndef HAVE_JUDY
9-
# include <set>
10-
# include <map>
11-
# include <unordered_map>
12-
#else // HAVE_JUDY
13-
# include "judyLArray.h"
14-
# include "judySArray.h"
15-
# include "judyL2Array.h"
16-
# include "judyS2Array.h"
17-
#endif // HAVE_JUDY
8+
#include "judyLArray.h"
9+
#include "judySArray.h"
10+
#include "judyL2Array.h"
11+
#include "judyS2Array.h"
1812

1913
class SDAI_Application_instance;
2014
class lazyDataSectionReader;
@@ -39,7 +33,7 @@ typedef int16_t fileID; ///< the index of a lazyFileReader in a lazyFileRea
3933
*/
4034
typedef uint64_t positionAndSection;
4135

42-
typedef std::vector< instanceID > * instanceRefs;
36+
typedef std::vector< instanceID > instanceRefs;
4337

4438
//TODO: create a "unique instance id" from the sectionID and instanceID, and use it everywhere?
4539

@@ -59,46 +53,21 @@ typedef struct {
5953
typedef struct {
6054
lazyInstanceLoc loc;
6155
const char * name;
62-
instanceRefs refs;
56+
instanceRefs * refs;
6357
} namedLazyInstance;
6458

6559
// instanceRefs - map between an instanceID and instances that refer to it
66-
#ifdef HAVE_JUDY
6760
typedef judyL2Array< instanceID, instanceID > instanceRefs_t;
68-
#else // HAVE_JUDY
69-
typedef std::unordered_multimap< instanceID, instanceID > instanceRefs_t;
70-
typedef std::pair< instanceID, instanceID > instanceRefs_pair;
71-
typedef std::pair< instanceRefs_t::const_iterator, instanceRefs_t::const_iterator > instanceRefs_range;
72-
#endif // HAVE_JUDY
7361

7462
// instanceType_t - multimap from instance type to instanceID's
75-
#ifdef HAVE_JUDY
7663
typedef judyS2Array< instanceID > instanceTypes_t;
77-
#else // HAVE_JUDY
78-
typedef std::unordered_multimap< std::string, instanceID > instanceTypes_t;
79-
typedef std::pair< std::string, instanceID > instanceTypes_pair;
80-
typedef std::pair< instanceTypes_t::const_iterator, instanceTypes_t::const_iterator > instanceTypes_range;
81-
#endif // HAVE_JUDY
8264

8365
// instancesLoaded - fully created instances
84-
#ifdef HAVE_JUDY
8566
typedef judyLArray< instanceID, SDAI_Application_instance * > instancesLoaded_t;
86-
#else // HAVE_JUDY
87-
typedef std::map< instanceID, SDAI_Application_instance * > instancesLoaded_t;
88-
typedef std::pair< instanceID, SDAI_Application_instance * > instancesLoaded_pair;
89-
#endif // HAVE_JUDY
9067

9168
// instanceStreamPos - map instance id to a streampos and data section
9269
// there could be multiple instances with the same ID, but in different files (or different sections of the same file?)
93-
#ifdef HAVE_JUDY
9470
typedef judyL2Array< instanceID, positionAndSection > instanceStreamPos_t;
95-
// typedef std::pair< instanceID, positionAndSection > instanceStreamPos_pair;
96-
// typedef std::pair< instanceStreamPos_t::cvector::const_iterator, instanceStreamPos_t::cvector::const_iterator > instanceStreamPos_range;
97-
#else // HAVE_JUDY
98-
typedef std::unordered_multimap< instanceID, positionAndSection > instanceStreamPos_t;
99-
typedef std::pair< instanceID, positionAndSection > instanceStreamPos_pair;
100-
typedef std::pair< instanceStreamPos_t::const_iterator, instanceStreamPos_t::const_iterator > instanceStreamPos_range;
101-
#endif // HAVE_JUDY
10271

10372

10473
// data sections

src/cllazyfile/lazy_test.cc

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
void fileInfo( lazyInstMgr& mgr, fileID id ) {
1313
instancesLoaded_t * headerInsts = mgr.getHeaderInstances( id );
1414
SDAI_Application_instance * hdrInst;
15-
#ifdef HAVE_JUDY
1615
hdrInst = headerInsts->find( 3 );
17-
#else //HAVE_JUDY
18-
instancesLoaded_t::iterator it = headerInsts.find( 3 );
19-
hdrInst = it->second;
20-
#endif //HAVE_JUDY
2116
if( ( hdrInst != 0 ) && ( hdrInst->STEPfile_id == 3 ) ) {
2217
SdaiFile_schema * fs = dynamic_cast< SdaiFile_schema * >( hdrInst );
2318
if( fs ) {
@@ -38,19 +33,13 @@ void countTypeInstances( lazyInstMgr & mgr, std::string type ) {
3833
std::cout << type << " instances: " << count;
3934
if( count ) {
4035
instanceID ex;
41-
#ifdef HAVE_JUDY
4236
ex = ( * mgr.getInstances( type ) )[ 0 ];
43-
#else //HAVE_JUDY
44-
instanceTypeMMap_range range = mgr.getInstances( type );
45-
ex = range.first->second; //this is the last based upon multimap hash value, not based on file order
46-
#endif //HAVE_JUDY
4737
std::cout << " -- example: #" << ex;
4838
}
4939
std::cout << std::endl;
5040
return;
5141
}
5242

53-
#ifdef HAVE_JUDY
5443
instanceID printRefs1( instanceRefs_t * refs, const char * desc ) {
5544
instanceID id = 0;
5645
instanceRefs_t::cpair p = refs->begin();
@@ -68,25 +57,6 @@ instanceID printRefs1( instanceRefs_t * refs, const char * desc ) {
6857
}
6958
return id;
7059
}
71-
#else //HAVE_JUDY
72-
instanceID printRefs1( instanceRefMap_range r, const char * desc ) {
73-
instanceRefMap_t::const_iterator it;
74-
if( r.first == r.second ) {
75-
std::cout << "No " << desc << " references" << std::endl;
76-
} else {
77-
it = r.first;
78-
for( ; it != r.second; it++ ) {
79-
std::cout << "Example of " << desc << " references - Instance #" << it->first << " makes use of ";
80-
auto frit = it->second->begin();
81-
for( ; frit != it->second->end(); frit++ ) {
82-
std::cout << *frit << " ";
83-
}
84-
std::cout << std::endl;
85-
break; //comment this out to loop through all
86-
}
87-
}
88-
}
89-
#endif //HAVE_JUDY
9060

9161
instanceID printRefs( lazyInstMgr & mgr ) {
9262
instanceID id;

src/cllazyfile/p21HeaderSectionReader.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ p21HeaderSectionReader::p21HeaderSectionReader( lazyFileReader * parent, std::if
2323
std::cerr << "lazy instance size: " << sizeof( nl.loc ) << std::endl;
2424
while( nl = nextInstance(), ( nl.loc.begin > 0 ) ) {
2525
std::streampos pos = _file.tellg();
26-
#ifdef HAVE_JUDY
2726
_headerInstances->insert( nl.loc.instance, getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), nl.loc.begin, nl.loc.instance, nl.name, "", true ) );
28-
#else //HAVE_JUDY
29-
_headerInstances.insert( instancesLoaded_pair( nl.loc.instance,
30-
getRealInstance( _lazyFile->getInstMgr()->getHeaderRegistry(), &nl.loc, nl.name, "", true ) ) );
31-
#endif //HAVE_JUDY
3227
_file.seekg( pos ); //reset stream position for next call to nextInstance()
3328
}
3429
_file.seekg( _sectionEnd );

src/cllazyfile/sectionReader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const char * sectionReader::getDelimitedKeyword( const char * delimiters ) {
108108
/// search forward in the file for the end of the instance. Start position should
109109
/// be the opening parenthesis; otherwise, it is likely to fail.
110110
///NOTE *must* check return value!
111-
std::streampos sectionReader::seekInstanceEnd( instanceRefs * refs ) {
111+
std::streampos sectionReader::seekInstanceEnd( instanceRefs ** refs ) {
112112
char c;
113113
int parenDepth = 0;
114114
while( c = _file.get(), _file.good() ) {

src/cllazyfile/sectionReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class sectionReader {
4141
const char * getDelimitedKeyword( const char * delimiters );
4242

4343
/** Seek to the end of the current instance */
44-
std::streampos seekInstanceEnd( instanceRefs * refs );
44+
std::streampos seekInstanceEnd( instanceRefs ** refs );
4545

4646
/// operator>> is very slow?!
4747
inline void skipWS() {

0 commit comments

Comments
 (0)