From 61db7b5badbe3dd84d3571cb3c3999fd454bb9c7 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Sat, 6 Aug 2011 23:35:28 +0100
Subject: [PATCH] OpenFOAM library: Add better error messaging from compound
 token transfer

---
 .../containers/Lists/FixedList/FixedListIO.C  |   2 +-
 src/OpenFOAM/containers/Lists/List/ListIO.C   |   2 +-
 .../db/IOstreams/token/CompoundToken.H        | 133 ------------------
 src/OpenFOAM/db/IOstreams/token/token.C       |  10 +-
 src/OpenFOAM/db/IOstreams/token/token.H       |   2 +-
 .../genericFvPatchField/genericFvPatchField.C |  10 +-
 .../genericPointPatchField.C                  |  10 +-
 7 files changed, 18 insertions(+), 151 deletions(-)
 delete mode 100644 src/OpenFOAM/db/IOstreams/token/CompoundToken.H

diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
index da7de7e8209..904c4f2902f 100644
--- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
+++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C
@@ -56,7 +56,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
         {
             L = dynamicCast<token::Compound<List<T> > >
             (
-                firstToken.transferCompoundToken()
+                firstToken.transferCompoundToken(is)
             );
         }
         else if (firstToken.isLabel())
diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C
index dda233bd841..8699f6126a6 100644
--- a/src/OpenFOAM/containers/Lists/List/ListIO.C
+++ b/src/OpenFOAM/containers/Lists/List/ListIO.C
@@ -59,7 +59,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
         (
             dynamicCast<token::Compound<List<T> > >
             (
-                firstToken.transferCompoundToken()
+                firstToken.transferCompoundToken(is)
             )
         );
     }
diff --git a/src/OpenFOAM/db/IOstreams/token/CompoundToken.H b/src/OpenFOAM/db/IOstreams/token/CompoundToken.H
deleted file mode 100644
index 915e6b6a973..00000000000
--- a/src/OpenFOAM/db/IOstreams/token/CompoundToken.H
+++ /dev/null
@@ -1,133 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
-     \\/     M anipulation  |
--------------------------------------------------------------------------------
-License
-    This file is part of OpenFOAM.
-
-    OpenFOAM is free software: you can redistribute it and/or modify it
-    under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
-    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-    for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
-
-Class
-    Foam::CompoundToken
-
-Description
-    An abstract base class for managing compound tokens
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef CompoundToken_H
-#define CompoundToken_H
-
-#include "refCount.H"
-#include "typeInfo.H"
-#include "autoPtr.H"
-#include "runTimeSelectionTables.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-// Forward declaration of friend functions and operators
-
-class CompoundToken;
-Ostream& operator<<(Ostream&, const CompoundToken&);
-
-
-/*---------------------------------------------------------------------------*\
-                           Class CompoundToken Declaration
-\*---------------------------------------------------------------------------*/
-
-class CompoundToken
-:
-    public refCount
-{
-    // Private Member Functions
-
-        //- Disallow default bitwise copy construct
-        CompoundToken(const CompoundToken&);
-
-        //- Disallow default bitwise assignment
-        void operator=(const CompoundToken&);
-
-
-public:
-
-    //- Runtime type information
-    virtual const word& type() const = 0;
-
-
-    // Declare run-time constructor selection tables
-
-        declareRunTimeSelectionTable
-        (
-            autoPtr,
-            CompoundToken,
-            Istream,
-            (const word& type, Istream& is),
-            (type, is)
-        );
-
-
-    // Constructors
-
-        //- Construct null
-        CompoundToken()
-        {}
-
-        //- Return the clone as this and increment reference count
-        virtual autoPtr<CompoundToken> clone() const = 0;
-
-
-    // Selectors
-
-        //- Select null constructed
-        static autoPtr<CompoundToken> New(const word& type, Istream& is);
-
-
-    //- Destructor
-    virtual ~CompoundToken();
-
-
-    // Member Functions
-
-        // Access
-
-        // Check
-
-        // Edit
-
-        // Write
-
-            virtual void write(Istream&) = 0;
-
-
-    // IOstream Operators
-
-        friend Ostream& operator<<(Ostream&, const CompoundToken&);
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/token/token.C b/src/OpenFOAM/db/IOstreams/token/token.C
index 6c57d1a1a9a..5d7ce3f2f70 100644
--- a/src/OpenFOAM/db/IOstreams/token/token.C
+++ b/src/OpenFOAM/db/IOstreams/token/token.C
@@ -63,11 +63,11 @@ Foam::autoPtr<Foam::token::compound> Foam::token::compound::New
 
     if (cstrIter == IstreamConstructorTablePtr_->end())
     {
-        FatalErrorIn("token::compound::New(const word&, Istream&)")
+        FatalIOErrorIn("token::compound::New(const word&, Istream&)", is)
             << "Unknown compound type " << compoundType << nl << nl
             << "Valid compound types:" << endl
             << IstreamConstructorTablePtr_->sortedToc()
-            << abort(FatalError);
+            << abort(FatalIOError);
     }
 
     return autoPtr<Foam::token::compound>(cstrIter()(is));
@@ -86,15 +86,15 @@ bool Foam::token::compound::isCompound(const word& name)
 }
 
 
-Foam::token::compound& Foam::token::transferCompoundToken()
+Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is)
 {
     if (type_ == COMPOUND)
     {
         if (compoundTokenPtr_->empty())
         {
-            FatalErrorIn("token::transferCompoundToken()")
+            FatalIOErrorIn("token::transferCompoundToken(const Istream& is)", is)
                 << "compound has already been transfered from token\n    "
-                << info() << abort(FatalError);
+                << info() << abort(FatalIOError);
         }
         else
         {
diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H
index 0c70cdc82e7..af754336195 100644
--- a/src/OpenFOAM/db/IOstreams/token/token.H
+++ b/src/OpenFOAM/db/IOstreams/token/token.H
@@ -351,7 +351,7 @@ public:
 
             inline bool isCompound() const;
             inline const compound& compoundToken() const;
-            compound& transferCompoundToken();
+            compound& transferCompoundToken(const Istream& is);
 
             inline label lineNumber() const;
             inline label& lineNumber();
diff --git a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
index 7587a7be485..1089b2576ee 100644
--- a/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
+++ b/src/genericPatchFields/genericFvPatchField/genericFvPatchField.C
@@ -147,7 +147,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
                         (
                             dynamicCast<token::Compound<List<scalar> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -184,7 +184,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
                         (
                             dynamicCast<token::Compound<List<vector> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -224,7 +224,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
                                 token::Compound<List<sphericalTensor> >
                             >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -264,7 +264,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
                                 token::Compound<List<symmTensor> >
                             >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -301,7 +301,7 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
                         (
                             dynamicCast<token::Compound<List<tensor> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
diff --git a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
index bb8fe3f6fe3..02f74a25c26 100644
--- a/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
+++ b/src/genericPatchFields/genericPointPatchField/genericPointPatchField.C
@@ -129,7 +129,7 @@ genericPointPatchField<Type>::genericPointPatchField
                         (
                             dynamicCast<token::Compound<List<scalar> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -167,7 +167,7 @@ genericPointPatchField<Type>::genericPointPatchField
                         (
                             dynamicCast<token::Compound<List<vector> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -208,7 +208,7 @@ genericPointPatchField<Type>::genericPointPatchField
                                 token::Compound<List<sphericalTensor> >
                             >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -249,7 +249,7 @@ genericPointPatchField<Type>::genericPointPatchField
                                 token::Compound<List<symmTensor> >
                             >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
@@ -287,7 +287,7 @@ genericPointPatchField<Type>::genericPointPatchField
                         (
                             dynamicCast<token::Compound<List<tensor> > >
                             (
-                                fieldToken.transferCompoundToken()
+                                fieldToken.transferCompoundToken(is)
                             )
                         );
 
-- 
GitLab