Commit 613eb0ab authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#634 Cosmetics. Apply DRY principle to the input parameter function that...

#634 Cosmetics. Apply DRY principle to the input parameter function that defines the name of the section.
parent 2079e925
......@@ -861,6 +861,9 @@
BE915A161AAF514900B4C474 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE915A151AAF514900B4C474 /* main.cpp */; };
BE9512901A8CC3E5009E0082 /* Mutex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE95128D1A8CC3E5009E0082 /* Mutex.hpp */; };
BE9512911A8CC3E5009E0082 /* Mutex.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE95128E1A8CC3E5009E0082 /* Mutex.hxx */; };
BE96FE981B820327009BC073 /* Section.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE96FE951B820327009BC073 /* Section.cpp */; };
BE96FE991B820327009BC073 /* Section.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE96FE961B820327009BC073 /* Section.hpp */; };
BE96FE9A1B820327009BC073 /* Section.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE96FE971B820327009BC073 /* Section.hxx */; };
BE9C4D171807F682005B94BC /* libFiniteElement.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE9C4D121807F5DC005B94BC /* libFiniteElement.a */; };
BEA2155517FD82320014AC13 /* libCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05B52916D238FE000E248D /* libCore.a */; settings = {ATTRIBUTES = (Required, ); }; };
BEA2155817FD82320014AC13 /* libGeometry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE05B4DD16D23573000E248D /* libGeometry.a */; };
......@@ -2860,6 +2863,9 @@
BE915A151AAF514900B4C474 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
BE95128D1A8CC3E5009E0082 /* Mutex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mutex.hpp; sourceTree = "<group>"; };
BE95128E1A8CC3E5009E0082 /* Mutex.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mutex.hxx; sourceTree = "<group>"; };
BE96FE951B820327009BC073 /* Section.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Section.cpp; path = Private/Section.cpp; sourceTree = "<group>"; };
BE96FE961B820327009BC073 /* Section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Section.hpp; path = Private/Section.hpp; sourceTree = "<group>"; };
BE96FE971B820327009BC073 /* Section.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Section.hxx; path = Private/Section.hxx; sourceTree = "<group>"; };
BE9C4D121807F5DC005B94BC /* libFiniteElement.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFiniteElement.a; sourceTree = BUILT_PRODUCTS_DIR; };
BE9D3EAC17CC7E890047D4F2 /* Base.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Base.hpp; sourceTree = "<group>"; };
BE9D3EAD17CC7E890047D4F2 /* Base.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = Base.hxx; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
......@@ -4451,6 +4457,7 @@
BE6AAE811AF7724300D420CB /* Crtp */,
BE6462251AEE199900D5162A /* Private */,
BE968B6917AB94A100995748 /* InputParameter */,
BE96FE941B8202E9009BC073 /* Private */,
);
name = Core;
path = Sources/Core;
......@@ -4977,6 +4984,17 @@
path = InputParameter;
sourceTree = "<group>";
};
BE96FE941B8202E9009BC073 /* Private */ = {
isa = PBXGroup;
children = (
BE96FE951B820327009BC073 /* Section.cpp */,
BE96FE961B820327009BC073 /* Section.hpp */,
BE96FE971B820327009BC073 /* Section.hxx */,
);
name = Private;
path = InputParameter;
sourceTree = "<group>";
};
BE9C4D001807F5BC005B94BC /* FiniteElement */ = {
isa = PBXGroup;
children = (
......@@ -6414,6 +6432,7 @@
BE90DED21A24903700CCAFDE /* InputParameterList.hpp in Headers */,
BE63C1771B21E51000978D05 /* TimeManagerInstance.hpp in Headers */,
BE2E0CCC1ABAFBA800B543E8 /* Mesh.hxx in Headers */,
BE96FE9A1B820327009BC073 /* Section.hxx in Headers */,
BE64622D1AEE199900D5162A /* NumberingSubsetManager.hpp in Headers */,
BEDAC3D51AD8102400AA2156 /* NumberingSubset.hxx in Headers */,
BE6322D91B18610200F787CC /* VolumicMass.hxx in Headers */,
......@@ -6434,6 +6453,7 @@
BE64623B1AEE1AEF00D5162A /* GlobalVector.hxx in Headers */,
BE90DEDC1A24903700CCAFDE /* Petsc.hpp in Headers */,
BE646CD91B1C4AEF001267F4 /* TransientSource.hpp in Headers */,
BE96FE991B820327009BC073 /* Section.hpp in Headers */,
BE63C16B1B21DFDD00978D05 /* ConstantTimeStep.hxx in Headers */,
BE40541A1AC1C14D0024D5F9 /* Unknown.hpp in Headers */,
BE6462341AEE1AE100D5162A /* GlobalMatrix.hpp in Headers */,
......@@ -7760,6 +7780,7 @@
BE45B90F1A9611D400812586 /* Petsc.cpp in Sources */,
BE8C17671B1C86A500514368 /* Tensor.cpp in Sources */,
1322D2A01B43C779009BEFD0 /* MitchellSchaeffer.cpp in Sources */,
BE96FE981B820327009BC073 /* Section.cpp in Sources */,
BE4478731AA70A1300665010 /* PrintAndAbort.cpp in Sources */,
BE6462291AEE199900D5162A /* NumberingSubset.cpp in Sources */,
BE6FB5DE1B4EC0CF00F0F6A3 /* ParameterUsualDescription.cpp in Sources */,
......
......@@ -87,7 +87,7 @@ namespace HappyHeart
};
} //namespace Crtp
} // namespace Crtp
} // namespace HappyHeart
......
......@@ -48,7 +48,7 @@ namespace HappyHeart
} //namespace Crtp
} // namespace Crtp
} // namespace HappyHeart
......
......@@ -137,7 +137,7 @@ namespace HappyHeart
}; //struct FEltSpace
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -86,7 +86,7 @@ namespace HappyHeart
}
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -87,7 +87,7 @@ namespace HappyHeart
}; // struct NumberingSubset
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -56,7 +56,7 @@ namespace HappyHeart
}
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -166,13 +166,13 @@ namespace HappyHeart
} //namespace FEltSpaceNS
} // namespace FEltSpaceNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......@@ -239,13 +239,13 @@ namespace HappyHeart
} //namespace FEltSpaceNS
} // namespace FEltSpaceNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -56,13 +56,13 @@ namespace HappyHeart
}
} //namespace NumberingSubsetNS
} // namespace NumberingSubsetNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......@@ -71,13 +71,13 @@ namespace HappyHeart
};
} //namespace NumberingSubsetNS
} // namespace NumberingSubsetNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -84,13 +84,13 @@ namespace HappyHeart
} //namespace UnknownNS
} // namespace UnknownNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......@@ -113,13 +113,13 @@ namespace HappyHeart
};
} //namespace UnknownNS
} // namespace UnknownNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -98,7 +98,7 @@ namespace HappyHeart
}; // struct Unknown
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -64,7 +64,7 @@ namespace HappyHeart
}
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -12,6 +12,7 @@
# include <string>
# include "Core/InputParameter/Geometry/Private/Domain.hpp"
# include "Core/InputParameter/Private/Section.hpp"
namespace HappyHeart
......@@ -27,6 +28,22 @@ namespace HappyHeart
{
/*!
* \brief Return the name of the section in the input parameter.
*
* e.g. 'Domain1' for IndexT = 1.
*/
static const std::string& SectionName();
/*!
* \brief Alias to the struct.
*
* \internal It is not called self here as it is intended to be used in classes enclosed in Domain.
*
*/
using enclosing_type = Domain<IndexT>;
//! Indicates the mesh upon which the domain is defined (if any).
struct MeshIndex : public Private::DomainNS::MeshIndex
{
......@@ -62,7 +79,7 @@ namespace HappyHeart
}; // struct Domain
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -18,66 +18,43 @@ namespace HappyHeart
{
namespace Private
template<unsigned int IndexT>
const std::string& Domain<IndexT>::SectionName()
{
namespace DomainNS
{
inline static const std::string& SectionNameWithoutIndex()
{
static std::string ret("Domain");
return ret;
}
//! Name of the section for all classes declared below.
template<unsigned int IndexT>
static const std::string& SectionNameWithIndex()
{
static std::string ret = SectionNameWithoutIndex() + std::to_string(IndexT);
return ret;
};
} // namespace DomainNS
} // namespace Private
static std::string ret = Private::GenerateSectionName("Domain", IndexT);
return ret;
};
template<unsigned int IndexT>
const std::string& Domain<IndexT>::MeshIndex::Section()
{
return Private::DomainNS::SectionNameWithIndex<IndexT>();
return enclosing_type::SectionName();
}
template<unsigned int IndexT>
const std::string& Domain<IndexT>::DimensionList::Section()
{
return Private::DomainNS::SectionNameWithIndex<IndexT>();
return enclosing_type::SectionName();
}
template<unsigned int IndexT>
const std::string& Domain<IndexT>::MeshLabelList::Section()
{
return Private::DomainNS::SectionNameWithIndex<IndexT>();
return enclosing_type::SectionName();
}
template<unsigned int IndexT>
const std::string& Domain<IndexT>::GeomEltTypeList::Section()
{
return Private::DomainNS::SectionNameWithIndex<IndexT>();
return enclosing_type::SectionName();
}
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
......
......@@ -12,6 +12,7 @@
# include <string>
# include "Core/InputParameter/Geometry/Private/Mesh.hpp"
# include "Core/InputParameter/Private/Section.hpp"
namespace HappyHeart
......
......@@ -22,9 +22,8 @@ namespace HappyHeart
template<unsigned int IndexT>
const std::string& Mesh<IndexT>::SectionName()
{
static std::string ret = Private::MeshNS::GenerateSectionName(IndexT);
static std::string ret = Private::GenerateSectionName("Mesh", IndexT);
return ret;
};
......
......@@ -27,6 +27,14 @@ namespace HappyHeart
{
std::string GenerateSectionName(unsigned int index)
{
std::ostringstream oconv;
oconv << "Domain" << index;
return oconv.str();
}
const std::string& MeshIndex::NameInFile()
{
static std::string ret("mesh_index");
......@@ -164,13 +172,13 @@ namespace HappyHeart
}
} //namespace DomainNS
} // namespace DomainNS
} //namespace Private
} // namespace Private
} //namespace InputParameter
} // namespace InputParameter
} // namespace HappyHeart
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