Merge pull request #4734 from OPM/fwk-adjustments

Add access to reference string
This commit is contained in:
Magne Sjaastad 2019-09-18 14:51:45 +02:00 committed by GitHub
commit 977771e3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 90 deletions

View File

@ -1,90 +0,0 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 130
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

View File

@ -43,6 +43,7 @@ public:
void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory) override;
void writeFieldData(QXmlStreamWriter& xmlStream) const override;
bool resolveReferences() override;
QString referenceString() const override;
private:
FieldType* m_field;

View File

@ -119,6 +119,15 @@ bool caf::PdmFieldXmlCap<FieldType>::resolveReferences()
return objHandle != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType>
QString caf::PdmFieldXmlCap<PdmPtrField<DataType*>>::referenceString() const
{
return m_referenceString;
}
//==================================================================================================
/// XML Implementation for PdmPtrArrayField<>
//==================================================================================================

View File

@ -42,6 +42,8 @@ public:
virtual bool resolveReferences() = 0;
virtual QString referenceString() const { return QString(); }
protected:
bool assertValid() const;
QString m_childClassKeyword; ///< Must be set in constructor of derived XmlFieldHandle

View File

@ -165,6 +165,8 @@ PdmObjectHandle* PdmXmlObjectHandle::readUnknownObjectFromXmlString(const QStrin
QString classKeyword = inputStream.name().toString();
PdmObjectHandle* newObject = objectFactory->create(classKeyword);
if (!newObject) return nullptr;
xmlObj(newObject)->readFields(inputStream, objectFactory);
return newObject;
@ -180,6 +182,8 @@ PdmObjectHandle* PdmXmlObjectHandle::copyByXmlSerialization(PdmObjectFactory* ob
QString xmlString = this->writeObjectToXmlString();
PdmObjectHandle* objectCopy = PdmXmlObjectHandle::readUnknownObjectFromXmlString(xmlString, objectFactory);
if (!objectCopy) return nullptr;
objectCopy->xmlCapability()->initAfterReadRecursively();
return objectCopy;
@ -195,6 +199,8 @@ caf::PdmObjectHandle* PdmXmlObjectHandle::copyAndCastByXmlSerialization(const QS
QString xmlString = this->writeObjectToXmlString();
PdmObjectHandle* upgradedObject = objectFactory->create(destinationClassKeyword);
if (!upgradedObject) return nullptr;
QXmlStreamReader inputStream(xmlString);
QXmlStreamReader::TokenType tt;