IOobjectTemplates.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 template<typename T, typename... Args>
23 (
24  const objectFile& objf,
25  Args&&... args
26 )
27 {
28  return makeUnique<IOobject>
29  (
30  objf, nullptr , make_object_t<T>(std::forward<Args>(args)...)
31  );
32 }
33 
34 template<typename T, typename... Args>
35 auto pFlow::IOobject::make_object_t(Args&&... args)
36 {
37  auto ptr = makeUnique<object_t<T>>(std::forward<Args>(args)...);
38  return ptr;
39 }
40 
41 template<typename T>
43 {
44  if( !isObjectValid() )
45  {
47  "accessing an invalid objecct "<< name() <<endl;
48  fatalExit;
49  }
50  return dynamic_cast<object_t<T>&>(*object_).data_;
51 }
52 
53 
54 template<typename T>
55 const auto& pFlow::IOobject::getObject()const
56 {
57  if( !isObjectValid() )
58  {
60  "accessing an invalid objecct "<< name() <<endl;
61  fatalExit;
62  }
63  return dynamic_cast<const object_t<T>&>(*object_).data_;
64 }
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::IOobject::object_t
Definition: IOobject.hpp:60
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::IOobject::getObject
auto & getObject()
Definition: IOobjectTemplates.cpp:42
pFlow::IOobject::make_object_t
static auto make_object_t(Args &&... args)
Definition: IOobjectTemplates.cpp:35
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::objectFile
Definition: objectFile.hpp:33
pFlow::IOobject::object_t::data_
dataType data_
Definition: IOobject.hpp:65
pFlow::IOobject::make
static auto make(const objectFile &objf, Args &&... args)
Definition: IOobjectTemplates.cpp:23