Commit Graph

15 Commits

Author SHA1 Message Date
Mark Olesen
129b738136 ENH: define IOobjectList::csorted(), deprecate some sorted() const methods
- prefer csorted() method for const access since it ensures that the
  return values are also const pointers (for example) even if
  the object itself can be accessed as a non-const.

- the csorted() method already existed for HashTable and
  objectRegistry, but now added to IOobjectList for method name
  consistency (even although the IOobjectList only has a const-access
  version)

ENH: objectRegistry with templated strict lookup

- for lookupClass and csorted/sorted. Allows isType restriction as a
  compile-time specification.
2023-07-31 20:11:32 +02:00
Mark Olesen
375a4792f9 ENH: HashSet, HashTable, HashPtrTable merge() method
- name and functionality similar to std::unordered_map (C++17).
  Formalizes what had been previously been implemented in IOobjectList
  but now manages without pointer deletion/creation.
2023-02-13 21:22:20 +01:00
Mark Olesen
21e7ce8f42 STYLE: place HashTable trivial methods in the header (reduce clutter) 2022-11-20 16:55:58 +01:00
Mark Olesen
95e2a2e887 ENH: add sorted() to objectRegistry and IOobjectList
- returns UPtrList view (read-only or read/write) of the objects

- shorter names for IOobject checks: hasHeaderClass(), isHeaderClass()

- remove unused IOobject::isHeaderClassName(const word&) method.
  The typed versions are preferable/recommended, but can still check
  directly if needed:

     (io.headerClassName() == "foo")
2022-05-17 17:35:51 +02:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
3c07a1bb6f ENH: Foam::name() of memory address
- returns the memory address formatted in hexadecimal, which can be
  useful for detailed information
2019-08-12 10:46:29 +02:00
Mark Olesen
59da4cf56d STYLE: use uintptr_t cast instead of long when reporting addresses 2019-04-29 08:15:48 +02:00
Mark Olesen
b81420e524 ENH: additional variants of IOobjectList findObject()
- cfindObject() for const pointer access.

- getObject() for mutable non-const pointer access, similar to the
     objectRegistry::getObjectPtr()

- cfindObject(), findObject(), getObject() with template type access
  to also check the headerClassName.

  For example,

      cfindObject("U")  ->  good
      cfindObject<volVectorField>("U") -> good
      cfindObject<volScalarField>("U") -> nullptr

  This allows inversion of looping logic.

    1) Obtain the names for a particular Type

       for (const word& objName : objs.sortedNames<Type>())
       {
           const IOobject* io = objs[objName];
           ...
       }

    2) Use previously obtained names and apply to a particular Type

       for (const word& objName : someListOfNames)
       {
           const IOobject* io = objs.cfindObject<Type>(objName);
           if (io)
           {
               ...
           }
       }
2018-11-28 11:28:38 +01:00
Mark Olesen
9bc61e5f41 ENH: improve IOobjectList name filtering
- support name filtering by class based on <Type> or predicates.
  Eg,

      objects.sortedNames<volScalarField>(namePattern);
  vs  objects.sortedNames(volScalarField::typeName, namePattern);

  These can also be used directly for untyped name matching.
  Eg,
      objects.sortedNames<void>(namePattern);

  Can also use a predicate:

      objects.sortedNames(wordRe("vol.*Field"), namePattern);
      objects.sortedNames
      (
          [](const word& clsName){ return clsName.startsWith("vol"); },
          namePattern
      );
2018-11-12 08:55:45 +01:00
Mark Olesen
faaa93fdb5 ENH: add IOobjectList::findObject() method
- naming similar to objectRegistry, with unambiguous resolution.
  The lookup() methods have different return types depending on the
  calling parameter.

STYLE: use IOobjectListTemplates.C for implementations

- previously included as local definition within IOobjectList.C,
  but will be adding more templated methods soon.

- adjust parameters (eg, matchName instead of matcher) to show their
  function

ENH: handle objectRegistry::names<void>(...)

- this is equivalent to no Type restriction, and can be used when
  filtering names. Eg,

     obr.names<void>(wordRe..);
2018-11-09 21:57:55 +01:00
Mark Olesen
db9cd2bc85 ENH: add IOobjectList append() method for building larger lists
- supports copy append and move append
2018-07-27 15:38:32 +02:00
Mark Olesen
c126464d1c ENH: change wordRes to be a List of wordRe instead of a wrapper (issue #259)
- this permits direct storage of a list with additional matcher
  capabilities

- provide wordRes::matcher class for similar behaviour as previously
2018-02-21 10:05:30 +01:00
Mark Olesen
345a2a42f1 ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
  and HashTable method names. This improves method name consistency
  between classes and also requires less typing effort:

    args.found(optName)        vs.  args.optionFound(optName)
    args.readIfPresent(..)     vs.  args.optionReadIfPresent(..)
    ...
    args.opt<scalar>(optName)  vs.  args.optionRead<scalar>(optName)
    args.read<scalar>(index)   vs.  args.argRead<scalar>(index)

- the older method names forms have been retained for code compatibility,
  but are now deprecated
2018-01-08 15:35:18 +01:00
Mark Olesen
9761e9d81e ENH: added classes() method to objectRegistry/IOobjectList
- provides a summary hash of classes used and their associated object names.

  The HashTable representation allows us to leverage various HashTable
  methods. This hashed summary view can be useful when querying
  particular aspects, but is most useful when reducing the objects in
  consideration to a particular subset. For example,

      const wordHashSet interestingTypes
      {
          volScalarField::typeName,
          volVectorField::typeName
      };

      IOobjectList objects(runTime, runTime.timeName());
      HashTable<wordHashSet> classes = objects.classes();

      classes.retain(interestingTypes);

      // Or do just the opposite:
      classes.erase(unsupportedTypes);

  Can also use the underlying HashTable filter methods

STYLE: use templated internals to avoid findString() when matching subsets
2017-05-17 10:43:24 +02:00