STYLE: additional notes for IOobject, regIOobject

This commit is contained in:
Mark Olesen
2019-11-20 11:55:47 +01:00
committed by Andrew Heather
parent 83d6aa424a
commit 06361f3f05
5 changed files with 43 additions and 45 deletions

View File

@ -246,31 +246,27 @@ Foam::IOobject Foam::IOobject::selectIO
Foam::word Foam::IOobject::group(const word& name)
{
word::size_type i = name.find_last_of('.');
const auto i = name.rfind('.');
if (i == word::npos || i == 0)
if (i == std::string::npos || i == 0)
{
return word::null;
}
else
{
return name.substr(i+1, word::npos);
}
return name.substr(i+1);
}
Foam::word Foam::IOobject::member(const word& name)
{
word::size_type i = name.find_last_of('.');
const auto i = name.rfind('.');
if (i == word::npos || i == 0)
if (i == std::string::npos || i == 0)
{
return name;
}
else
{
return name.substr(0, i);
}
return name.substr(0, i);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,6 +64,14 @@ Description
- \par NO_WRITE
No automatic write on destruction but can be written explicitly
Note
Specifying registered does not result in the IOobject itself being
registered. It is only serves as guidance for a regIOobject using it.
See also
Foam::objectRegistry
Foam::regIOobject
SourceFiles
IOobject.C
IOobjectReadHeader.C
@ -164,10 +172,10 @@ private:
//- Write option
writeOption wOpt_;
//- Register object created from this IOobject with registry if true
//- Should object created with this IOobject be registered?
bool registerObject_;
//- Is object same for all processors
//- Is object same for all processors?
bool globalObject_;
//- IOobject state
@ -226,6 +234,7 @@ public:
);
//- Create dot-delimited name.group
// If the group is an empty string, it is ignored.
template<class StringType>
static inline word groupName(StringType name, const word& group);
@ -362,16 +371,16 @@ public:
name_ = newName;
}
//- Register object created from this IOobject with registry if true
//- Should object created with this IOobject be registered?
inline bool registerObject() const;
//- Register object created from this IOobject with registry if true
//- Should object created with this IOobject be registered?
inline bool& registerObject();
//- Is object same for all processors
//- Is object same for all processors?
inline bool globalObject() const;
//- Is object same for all processors
//- Is object same for all processors?
inline bool& globalObject();
//- The label byte-size, possibly read from the header
@ -514,7 +523,7 @@ public:
}
// Member operators
// Member Operators
void operator=(const IOobject& io);
};

View File

@ -62,16 +62,11 @@ Foam::regIOobject::regIOobject(const IOobject& io, const bool isTime)
registered_(false),
ownedByRegistry_(false),
watchIndices_(),
eventNo_ // Do not get event for top level Time database
(
isTime
? 0
: db().getEvent()
)
eventNo_(isTime ? 0 : db().getEvent()) // No event for top-level Time
{
// Register with objectRegistry if requested
if (registerObject())
{
// Register (check-in) with objectRegistry if requested
checkIn();
}
}

View File

@ -134,34 +134,35 @@ public:
// Constructors
//- Construct from IOobject with optional flag if IOobject is the
//- top-level regIOobject.
regIOobject(const IOobject&, const bool isTime = false);
//- Construct from IOobject. The optional flag adds special handling
//- if the object is the top-level regIOobject (eg, Time).
regIOobject(const IOobject& io, const bool isTime = false);
//- Copy construct
regIOobject(const regIOobject&);
regIOobject(const regIOobject& rio);
//- Copy construct, transferring registry registration to the copy
//- if registerCopy is true
regIOobject(const regIOobject&, bool registerCopy);
regIOobject(const regIOobject& rio, bool registerCopy);
//- Copy construct with new name, transferring registry registration
//- to the copy f registerCopy is true
regIOobject(const word& newName, const regIOobject&, bool registerCopy);
//- Construct as copy with new IO parameters
regIOobject(const IOobject&, const regIOobject&);
//- Copy construct with new IO parameters
regIOobject(const IOobject& io, const regIOobject& rio);
//- Destructor
virtual ~regIOobject();
// Member functions
// Member Functions
// Registration
//- Add object to registry
//- Add object to registry, if not already registered
// \return true if object was newly registered
bool checkIn();
//- Remove all file watches and remove object from registry
@ -178,17 +179,17 @@ public:
inline void store();
//- Transfer ownership of the given object pointer to its registry
// and return reference to object.
// \return reference to the object.
template<class Type>
inline static Type& store(Type* p);
//- Transfer ownership of the given object pointer to its registry
//- and return reference to object.
// \return reference to the object.
template<class Type>
inline static Type& store(autoPtr<Type>& aptr);
//- Transfer ownership of the given object pointer to its registry
//- and return reference to object.
// \return reference to the object.
template<class Type>
inline static Type& store(autoPtr<Type>&& aptr);
@ -206,11 +207,9 @@ public:
inline label& eventNo();
//- Return true if up-to-date with respect to given object
// otherwise false
bool upToDate(const regIOobject&) const;
//- Return true if up-to-date with respect to given objects
// otherwise false
bool upToDate
(
const regIOobject&,
@ -218,7 +217,6 @@ public:
) const;
//- Return true if up-to-date with respect to given objects
// otherwise false
bool upToDate
(
const regIOobject&,
@ -227,7 +225,6 @@ public:
) const;
//- Return true if up-to-date with respect to given objects
// otherwise false
bool upToDate
(
const regIOobject&,
@ -236,7 +233,8 @@ public:
const regIOobject&
) const;
//- Set up to date (obviously)
//- Set as up-to-date
void setUpToDate();

View File

@ -46,7 +46,7 @@ inline Type& Foam::regIOobject::store(Type* p)
if (!p)
{
FatalErrorInFunction
<< "object deallocated"
<< "Object deallocated\n"
<< abort(FatalError);
}