From fb61337175a9e7a31f397edff3a4e10c5911873f Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 5 Oct 2012 02:30:54 -0700 Subject: [PATCH] Simplifications. Concurrency fixes. Make "non binary" fields (like 'id') work. --- src/FieldNames.cpp | 7 +------ src/FieldNames.h | 14 ++++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/FieldNames.cpp b/src/FieldNames.cpp index 7872f87c2e..2946ca2552 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -31,7 +31,7 @@ SField::ref SField::getField(int code) int type = code >> 16; int field = code % 0xffff; - if ((type <= 0) || (type >= 256) || (field <= 0) || (field >= 256)) + if ((type <= 0) || (field <= 0)) return sfInvalid; boost::mutex::scoped_lock sl(mapMutex); @@ -72,11 +72,6 @@ int SField::compare(SField::ref f1, SField::ref f2) return 0; } -SField::ref SField::getField(int type, int value) -{ - return getField(FIELD_CODE(type, value)); -} - std::string SField::getName() const { if (!fieldName.empty()) diff --git a/src/FieldNames.h b/src/FieldNames.h index 3316ae492d..cea532fb63 100644 --- a/src/FieldNames.h +++ b/src/FieldNames.h @@ -52,20 +52,26 @@ public: SField(int fc, SerializedTypeID tid, int fv, const char* fn) : fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn) - { codeToField[fieldCode] = this; } + { + boost::mutex::scoped_lock sl(mapMutex); + codeToField[fieldCode] = this; + } SField(SerializedTypeID tid, int fv, const char *fn) : fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn) - { codeToField[fieldCode] = this; } + { + boost::mutex::scoped_lock sl(mapMutex); + codeToField[fieldCode] = this; + } SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0) { ; } ~SField(); static SField::ref getField(int fieldCode); - static SField::ref getField(int fieldType, int fieldValue); static SField::ref getField(const std::string& fieldName); - static SField::ref getField(SerializedTypeID type, int value) { return getField(FIELD_CODE(type, value)); } + static SField::ref getField(int type, int value) { return getField(FIELD_CODE(type, value)); } + static SField::ref getField(SerializedTypeID type, int value) { return getField(FIELD_CODE(type, value)); } std::string getName() const; bool hasName() const { return !fieldName.empty(); }