Commit 19503c93 authored by Mark Olesen's avatar Mark Olesen
Browse files

rename xfer<T> class to Xfer<T>

- The capitalization is consistent with most other template classes, but
  more importantly frees up xfer() for use as method name without needing
  special treatment to avoid ambiguities.

  It seems reasonable to have different names for transfer(...) and xfer()
  methods, since the transfer is occuring in different directions.
  The xfer() method can thus replace the recently introduced zero-parameter
  transfer() methods.
  Other name candidates (eg, yield, release, etc.) were deemed too abstract.
parent 461ac4b4
......@@ -145,14 +145,22 @@ int main(int argc, char *argv[])
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
List<label> lstB(dlC.transfer());
List<label> lstB(dlC.xfer());
Info<< "Transferred to normal list via the transfer() method" << endl;
Info<< "Transferred to normal list via the xfer() method" << endl;
Info<< "<lstB>" << lstB << "</lstB>" << nl << "sizes: "
<< " " << lstB.size() << endl;
Info<< "<dlC>" << dlC << "</dlC>" << nl << "sizes: "
<< " " << dlC.size() << "/" << dlC.capacity() << endl;
DynamicList<label> dlD(lstB.xfer());
Info<< "Transfer construct from normal list" << endl;
Info<< "<lstB>" << lstB << "</lstB>" << nl << "sizes: "
<< " " << lstB.size() << endl;
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
return 0;
}
......
......@@ -91,10 +91,10 @@ int main()
HASHTABLE_CLASS<double> table2(table1);
HASHTABLE_CLASS<double> table3(table1.transfer());
HASHTABLE_CLASS<double> table3(table1.xfer());
Info<< "\ncopy table1 -> table2" << nl
<< "transfer table1 -> table3 via the transfer() method" << nl;
<< "transfer table1 -> table3 via the xfer() method" << nl;
Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table1 << nl
......
......@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
Info<< "table3: " << table3 << nl
<< "toc: " << table3.toc() << endl;
Map<label> table4(table3.transfer());
Map<label> table4(table3.xfer());
Info<< "table3: " << table3 << nl
<< "toc: " << table3.toc() << endl;
......
......@@ -54,10 +54,10 @@ int main(int argc, char *argv[])
list2.setSize(10, vector(1, 2, 3));
Info<< list2 << endl;
List<vector> list3(list2.transfer());
Info<< "Transferred via the transfer() method" << endl;
Info<< list2 << endl;
Info<< list3 << endl;
List<vector> list3(list2.xfer());
Info<< "Transferred via the xfer() method" << endl;
Info<< list2 << nl
<< list3 << endl;
return 0;
}
......
......@@ -104,8 +104,8 @@ int main(int argc, char *argv[])
Info<<"list1: " << list1 << endl;
PtrList<Scalar> list3(list1.transfer());
Info<< "Transferred via the transfer() method" << endl;
PtrList<Scalar> list3(list1.xfer());
Info<< "Transferred via the xfer() method" << endl;
Info<<"list1: " << list1 << endl;
Info<<"list2: " << list2 << endl;
......
......@@ -91,10 +91,10 @@ int main()
HASHTABLE_CLASS<double> table2(table1);
HASHTABLE_CLASS<double> table3(table1.transfer());
HASHTABLE_CLASS<double> table3(table1.xfer());
Info<< "\ncopy table1 -> table2" << nl
<< "transfer table1 -> table3 via the transfer() method" << nl;
<< "transfer table1 -> table3 via the xfer() method" << nl;
Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table1 << nl
......
......@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
<< "keys: " << dict1.keys() << nl
<< "patterns: " << dict1.keys(true) << endl;
dictionary dict2(dict1.transfer());
dictionary dict2(dict1.xfer());
Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << nl
<< "dict2.toc(): " << dict2.name() << " " << dict2.toc() << endl;
......
......@@ -56,8 +56,8 @@ int main(int argc, char *argv[])
Info<< "lstA: " << lstA << endl;
Info<< "lstC: " << lstC << endl;
xfer<List<label> > xA = xferMove(lstA);
xfer<List<label> > xB;
Xfer<List<label> > xA = xferMove(lstA);
Xfer<List<label> > xB;
List<label> lstB( xA );
......@@ -112,8 +112,8 @@ int main(int argc, char *argv[])
Info<< "f1: " << f1 << endl;
Info<< "f2: " << f2 << endl;
// note: using xferMoveTo to ensure the correct transfer() method is called
face f3( xferMoveTo<labelList>(dl) );
// note: xfer() method returns a plain labelList
face f3( dl.xfer() );
Info<< "dl[" << dl.size() << "/" << dl.capacity() << "] " << dl << endl;
Info<< "f3: " << f3 << endl;
......
......@@ -48,7 +48,7 @@ template
template<class> class FaceList,
class PointField
>
Foam::xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
Foam::Xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
......@@ -82,7 +82,7 @@ Foam::xfer<Foam::pointField> Foam::extrudedMesh::extrudedPoints
template<class Face, template<class> class FaceList, class PointField>
Foam::xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
Foam::Xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
......@@ -184,7 +184,7 @@ Foam::xfer<Foam::faceList> Foam::extrudedMesh::extrudedFaces
template<class Face, template<class> class FaceList, class PointField>
Foam::xfer<Foam::cellList> Foam::extrudedMesh::extrudedCells
Foam::Xfer<Foam::cellList> Foam::extrudedMesh::extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel& model
......
......@@ -63,7 +63,7 @@ class extrudedMesh
//- Construct and return the extruded mesh points
template<class Face, template<class> class FaceList, class PointField>
xfer<pointField> extrudedPoints
Xfer<pointField> extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
......@@ -71,7 +71,7 @@ class extrudedMesh
//- Construct and return the extruded mesh faces
template<class Face, template<class> class FaceList, class PointField>
xfer<faceList> extrudedFaces
Xfer<faceList> extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
......@@ -79,7 +79,7 @@ class extrudedMesh
//- Construct and return the extruded mesh cells
template<class Face, template<class> class FaceList, class PointField>
xfer<cellList> extrudedCells
Xfer<cellList> extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const extrudeModel&
......
......@@ -316,7 +316,7 @@ autoPtr<mapPolyMesh> reorderMesh
mesh.resetPrimitives
(
xfer<pointField>::null(),
Xfer<pointField>::null(),
xferMove(newFaces),
xferMove(newOwner),
xferMove(newNeighbour),
......
......@@ -175,13 +175,10 @@ Istream& operator>>(Istream& is, HashPtrTable<T, Key, Hash>& L)
template<class T, class Key, class Hash>
Ostream& operator<<(Ostream& os, const HashPtrTable<T, Key, Hash>& L)
{
// Write size of HashPtrTable
os << nl << L.size();
// Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
// Write beginning of contents
os << nl << token::BEGIN_LIST << nl;
// Write HashPtrTable contents
// Write contents
for
(
typename HashPtrTable<T, Key, Hash>::const_iterator iter = L.begin();
......@@ -192,7 +189,7 @@ Ostream& operator<<(Ostream& os, const HashPtrTable<T, Key, Hash>& L)
os << iter.key() << token::SPACE << *iter() << nl;
}
// Write end of contents
// Write end delimiter
os << token::END_LIST;
// Check state of IOstream
......
......@@ -101,13 +101,13 @@ public:
{}
//- Construct by transferring the parameter contents
HashSet(const xfer<HashSet<Key, Hash> >& hs)
HashSet(const Xfer<HashSet<Key, Hash> >& hs)
:
HashTable<empty, Key, Hash>(hs)
{}
//- Construct by transferring the parameter contents
HashSet(const xfer<HashTable<empty, Key, Hash> >& hs)
HashSet(const Xfer<HashTable<empty, Key, Hash> >& hs)
:
HashTable<empty, Key, Hash>(hs)
{}
......
......@@ -81,7 +81,7 @@ Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht)
template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>::HashTable
(
const xfer<HashTable<T, Key, Hash> >& ht
const Xfer<HashTable<T, Key, Hash> >& ht
)
:
HashTableName(),
......
......@@ -41,7 +41,7 @@ SourceFiles
#include "label.H"
#include "word.H"
#include "className.H"
#include "xfer.H"
#include "Xfer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -156,7 +156,7 @@ public:
HashTable(const HashTable<T, Key, Hash>&);
//- Construct by transferring the parameter contents
HashTable(const xfer<HashTable<T, Key, Hash> >&);
HashTable(const Xfer<HashTable<T, Key, Hash> >&);
// Destructor
......@@ -214,8 +214,8 @@ public:
// and annull the argument table.
void transfer(HashTable<T, Key, Hash>&);
//- Transfer the contents to the xfer container
inline xfer<HashTable<T, Key, Hash> > transfer();
//- Transfer contents to the Xfer container
inline Xfer<HashTable<T, Key, Hash> > xfer();
// Member Operators
......
......@@ -74,12 +74,10 @@ inline bool Foam::HashTable<T, Key, Hash>::set
template<class T, class Key, class Hash>
inline Foam::xfer<Foam::HashTable<T, Key, Hash> >
Foam::HashTable<T, Key, Hash>::transfer()
inline Foam::Xfer<Foam::HashTable<T, Key, Hash> >
Foam::HashTable<T, Key, Hash>::xfer()
{
Foam::xfer<HashTable<T, Key, Hash> > xf;
xf().transfer(*this);
return xf;
return xferMove(*this);
}
......
......@@ -168,7 +168,7 @@ Foam::Istream& Foam::operator>>(Istream& is, HashTable<T, Key, Hash>& L)
template<class T, class Key, class Hash>
Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable<T, Key, Hash>& L)
{
// Write size of HashTable and start contents delimiter
// Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
// Write contents
......@@ -182,7 +182,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const HashTable<T, Key, Hash>& L)
os << iter.key() << token::SPACE << iter() << nl;
}
// Write end of contents delimiter
// Write end delimiter
os << token::END_LIST;
// Check state of IOstream
......
......@@ -81,13 +81,13 @@ public:
{}
//- Construct by transferring the parameter contents
Map(const xfer<Map<T> >& map)
Map(const Xfer<Map<T> >& map)
:
HashTable<T, label, Hash<label> >(map)
{}
//- Construct by transferring the parameter contents
Map(const xfer<HashTable<T, label, Hash<label> > >& map)
Map(const Xfer<HashTable<T, label, Hash<label> > >& map)
:
HashTable<T, label, Hash<label> >(map)
{}
......
......@@ -75,7 +75,7 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
template<class T, class Key, class Hash>
Foam::StaticHashTable<T, Key, Hash>::StaticHashTable
(
const xfer<StaticHashTable<T, Key, Hash> >& ht
const Xfer<StaticHashTable<T, Key, Hash> >& ht
)
:
StaticHashTableName(),
......
......@@ -47,7 +47,7 @@ SourceFiles
#include "label.H"
#include "word.H"
#include "className.H"
#include "xfer.H"
#include "Xfer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -150,7 +150,7 @@ public:
StaticHashTable(const StaticHashTable<T, Key, Hash>&);
//- Construct by transferring the parameter contents
StaticHashTable(const xfer<StaticHashTable<T, Key, Hash> >&);
StaticHashTable(const Xfer<StaticHashTable<T, Key, Hash> >&);
// Destructor
......@@ -207,8 +207,8 @@ public:
// and annull the argument table.
void transfer(StaticHashTable<T, Key, Hash>&);
//- Transfer the contents to the xfer container
inline xfer<StaticHashTable<T, Key, Hash> > transfer();
//- Transfer contents to the Xfer container
inline Xfer<StaticHashTable<T, Key, Hash> > xfer();
// Member Operators
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment