From c16cbe6d7f54a23d3cfedcd0c78f4a9d4b479ce8 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Sun, 18 Aug 2024 17:04:55 -0500 Subject: [PATCH] [clib] Rename SharedCabinet to Cabinet Revert to original name after SharedCabinet was introduced in #1448 and the original Cabinet was subsequently removed. --- src/clib/Cabinet.h | 52 +++++++++++++++++++-------------------- src/clib/ct.cpp | 8 +++--- src/clib/ctfunc.cpp | 4 +-- src/clib/ctmultiphase.cpp | 4 +-- src/clib/ctonedim.cpp | 12 ++++----- src/clib/ctreactor.cpp | 18 +++++++------- src/clib/ctrpath.cpp | 6 ++--- src/clib/ctsurf.cpp | 2 +- src/fortran/fct.cpp | 6 ++--- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/clib/Cabinet.h b/src/clib/Cabinet.h index 29957a1016..fba097747f 100644 --- a/src/clib/Cabinet.h +++ b/src/clib/Cabinet.h @@ -16,39 +16,39 @@ namespace Cantera { /** - * Template for classes to hold pointers to objects. The SharedCabinet class + * Template for classes to hold pointers to objects. The Cabinet class * maintains a list of pointers to objects of class M (or of subclasses of M). These * classes are used by the 'clib' interface library functions that provide access to * %Cantera C++ objects from outside C++. To refer to an existing object, the library * functions take an integer argument that specifies the location in the pointer list - * maintained by the appropriate SharedCabinet instance. The pointer is retrieved + * maintained by the appropriate Cabinet instance. The pointer is retrieved * from the list by the interface function, the desired method is invoked, and the * result returned to the non-C++ calling procedure. By storing the pointers in a - * SharedCabinet, there is no need to encode them in a string or integer and pass + * Cabinet, there is no need to encode them in a string or integer and pass * them out to the non-C++ calling routine, as some other interfacing schemes do. * - * The SharedCabinet class can be used to store pointers to arbitrary objects. In + * The Cabinet class can be used to store pointers to arbitrary objects. In * most cases, class M is a base class with virtual methods, and the base class versions * of the methods throw CanteraError exceptions. The subclasses overload these methods - * to implement the desired functionality. Class SharedCabinet stores only the + * to implement the desired functionality. Class Cabinet stores only the * base-class pointers, but since the methods are virtual, the method of the appropriate * subclass will be invoked. * - * As the SharedCabinet class uses smart pointers, it is set up to allow deleting + * As the Cabinet class uses smart pointers, it is set up to allow deleting * objects in an inherently safe manner. Method 'del' does the following. If called * with n >= 0, it dereferences the object. The original object is only destroyed if the * reference is not shared by other objects. In this way, if it is deleted again * inadvertently nothing happens, and if an attempt is made to reference the object by * its index number, a standard exception is thrown. * - * The SharedCabinet class is implemented as a singleton. The constructor is never - * explicitly called; instead, static function SharedCabinet::SharedCabinet() is + * The Cabinet class is implemented as a singleton. The constructor is never + * explicitly called; instead, static function Cabinet::Cabinet() is * called to obtain a pointer to the instance. This function calls the constructor on * the first call and stores the pointer to this instance. Subsequent calls simply * return the already-created pointer. */ template -class SharedCabinet +class Cabinet { public: typedef vector>& dataRef; @@ -57,7 +57,7 @@ class SharedCabinet /** * Constructor. */ - SharedCabinet() {} + Cabinet() {} /** * Add a new object. The index of the object is returned. @@ -113,7 +113,7 @@ class SharedCabinet try { return add(*data[n]); // do not copy parent to avoid ambiguous data } catch (std::exception& err) { - throw CanteraError("SharedCabinet::newCopy", err.what()); + throw CanteraError("Cabinet::newCopy", err.what()); } } @@ -125,7 +125,7 @@ class SharedCabinet if (n >= 0 && n < len(data)) { lookupRef lookup = getLookup(); if (!lookup.count(data[n].get())) { - throw CanteraError("SharedCabinet::del", + throw CanteraError("Cabinet::del", "Lookup table does not contain reference to object."); } if (lookup[data[n].get()].size() == 1) { @@ -137,7 +137,7 @@ class SharedCabinet } data[n].reset(); } else { - throw CanteraError("SharedCabinet::del", + throw CanteraError("Cabinet::del", "Attempt made to delete a non-existing object."); } } @@ -148,7 +148,7 @@ class SharedCabinet static int parent(int n) { auto& parents = getParents(); if (n < 0 || n >= len(parents)) { - throw CanteraError("SharedCabinet::parent", "Index {} out of range.", n); + throw CanteraError("Cabinet::parent", "Index {} out of range.", n); } return parents[n]; } @@ -159,10 +159,10 @@ class SharedCabinet static shared_ptr& at(int n) { dataRef data = getData(); if (n < 0 || n >= len(data)) { - throw CanteraError("SharedCabinet::at", "Index {} out of range.", n); + throw CanteraError("Cabinet::at", "Index {} out of range.", n); } if (!data[n]) { - throw CanteraError("SharedCabinet::at", + throw CanteraError("Cabinet::at", "Object with index {} has been deleted.", n); } return data[n]; @@ -177,12 +177,12 @@ class SharedCabinet if (obj) { return obj; } - throw CanteraError("SharedCabinet::as", "Item is not of the correct type."); + throw CanteraError("Cabinet::as", "Item is not of the correct type."); } /** - * Return the index in the SharedCabinet to the specified object, or -1 if the - * object is not in the SharedCabinet. If multiple indices reference the same + * Return the index in the Cabinet to the specified object, or -1 if the + * object is not in the Cabinet. If multiple indices reference the same * object, the index of the last one added is returned. */ static int index(const M& obj, int parent=-1) { @@ -203,36 +203,36 @@ class SharedCabinet private: /** * Static function that returns a pointer to the data member of - * the singleton SharedCabinet instance. All member functions should + * the singleton Cabinet instance. All member functions should * access the data through this function. */ static dataRef getData() { if (s_storage == nullptr) { - s_storage = new SharedCabinet(); + s_storage = new Cabinet(); } return s_storage->m_table; } /** * Static function that returns a pointer to the list of parent object handles of - * the singleton SharedCabinet instance. All member functions should + * the singleton Cabinet instance. All member functions should * access the data through this function. */ static vector& getParents() { if (s_storage == nullptr) { - s_storage = new SharedCabinet(); + s_storage = new Cabinet(); } return s_storage->m_parents; } /** * Static function that returns a pointer to the reverse lookup table of - * the singleton SharedCabinet instance. All member functions should + * the singleton Cabinet instance. All member functions should * access the lookup table through this function. */ static lookupRef getLookup() { if (s_storage == nullptr) { - s_storage = new SharedCabinet(); + s_storage = new Cabinet(); } return s_storage->m_lookup; } @@ -240,7 +240,7 @@ class SharedCabinet /** * Pointer to the single instance of this class. */ - static SharedCabinet* s_storage; + static Cabinet* s_storage; /** * Reverse lookup table for the single instance of this class. diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 60c6a0948e..6de2cd932a 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -28,10 +28,10 @@ using namespace Cantera; -typedef SharedCabinet ThermoCabinet; -typedef SharedCabinet KineticsCabinet; -typedef SharedCabinet TransportCabinet; -typedef SharedCabinet SolutionCabinet; +typedef Cabinet ThermoCabinet; +typedef Cabinet KineticsCabinet; +typedef Cabinet TransportCabinet; +typedef Cabinet SolutionCabinet; template<> ThermoCabinet* ThermoCabinet::s_storage = 0; template<> KineticsCabinet* KineticsCabinet::s_storage = 0; diff --git a/src/clib/ctfunc.cpp b/src/clib/ctfunc.cpp index cb6c63dacc..95918f9179 100644 --- a/src/clib/ctfunc.cpp +++ b/src/clib/ctfunc.cpp @@ -15,8 +15,8 @@ using namespace Cantera; -typedef SharedCabinet FuncCabinet; -// Assign storage to the SharedCabinet static member +typedef Cabinet FuncCabinet; +// Assign storage to the Cabinet static member template<> FuncCabinet* FuncCabinet::s_storage = 0; extern "C" { diff --git a/src/clib/ctmultiphase.cpp b/src/clib/ctmultiphase.cpp index a85d5933cf..653e1c388a 100644 --- a/src/clib/ctmultiphase.cpp +++ b/src/clib/ctmultiphase.cpp @@ -14,8 +14,8 @@ using namespace Cantera; -typedef SharedCabinet mixCabinet; -typedef SharedCabinet ThermoCabinet; +typedef Cabinet mixCabinet; +typedef Cabinet ThermoCabinet; template<> mixCabinet* mixCabinet::s_storage = 0; template<> ThermoCabinet* ThermoCabinet::s_storage; // defined in ct.cpp diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index 5da90015bd..f8594d45e1 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -20,15 +20,15 @@ using namespace std; using namespace Cantera; -typedef SharedCabinet SimCabinet; -typedef SharedCabinet DomainCabinet; +typedef Cabinet SimCabinet; +typedef Cabinet DomainCabinet; template<> SimCabinet* SimCabinet::s_storage = 0; template<> DomainCabinet* DomainCabinet::s_storage = 0; -typedef SharedCabinet ThermoCabinet; -typedef SharedCabinet KineticsCabinet; -typedef SharedCabinet TransportCabinet; -typedef SharedCabinet SolutionCabinet; +typedef Cabinet ThermoCabinet; +typedef Cabinet KineticsCabinet; +typedef Cabinet TransportCabinet; +typedef Cabinet SolutionCabinet; template<> ThermoCabinet* ThermoCabinet::s_storage; // defined in ct.cpp template<> KineticsCabinet* KineticsCabinet::s_storage; // defined in ct.cpp template<> TransportCabinet* TransportCabinet::s_storage; // defined in ct.cpp diff --git a/src/clib/ctreactor.cpp b/src/clib/ctreactor.cpp index 7f19fad0cc..c3eea3f78a 100644 --- a/src/clib/ctreactor.cpp +++ b/src/clib/ctreactor.cpp @@ -16,15 +16,15 @@ using namespace Cantera; -typedef SharedCabinet ReactorCabinet; -typedef SharedCabinet NetworkCabinet; -typedef SharedCabinet FlowDeviceCabinet; -typedef SharedCabinet WallCabinet; -typedef SharedCabinet FuncCabinet; -typedef SharedCabinet ThermoCabinet; -typedef SharedCabinet KineticsCabinet; -typedef SharedCabinet SolutionCabinet; -typedef SharedCabinet ReactorSurfaceCabinet; +typedef Cabinet ReactorCabinet; +typedef Cabinet NetworkCabinet; +typedef Cabinet FlowDeviceCabinet; +typedef Cabinet WallCabinet; +typedef Cabinet FuncCabinet; +typedef Cabinet ThermoCabinet; +typedef Cabinet KineticsCabinet; +typedef Cabinet SolutionCabinet; +typedef Cabinet ReactorSurfaceCabinet; template<> ReactorCabinet* ReactorCabinet::s_storage = 0; template<> NetworkCabinet* NetworkCabinet::s_storage = 0; diff --git a/src/clib/ctrpath.cpp b/src/clib/ctrpath.cpp index 63647af862..3b65d44bd1 100644 --- a/src/clib/ctrpath.cpp +++ b/src/clib/ctrpath.cpp @@ -16,12 +16,12 @@ using namespace Cantera; using namespace std; -typedef SharedCabinet BuilderCabinet; -typedef SharedCabinet DiagramCabinet; +typedef Cabinet BuilderCabinet; +typedef Cabinet DiagramCabinet; template<> DiagramCabinet* DiagramCabinet::s_storage = 0; template<> BuilderCabinet* BuilderCabinet::s_storage = 0; -typedef SharedCabinet KineticsCabinet; +typedef Cabinet KineticsCabinet; template<> KineticsCabinet* KineticsCabinet::s_storage; // defined in ct.cpp extern "C" { diff --git a/src/clib/ctsurf.cpp b/src/clib/ctsurf.cpp index 11e866c2d8..0d66fce6b9 100644 --- a/src/clib/ctsurf.cpp +++ b/src/clib/ctsurf.cpp @@ -14,7 +14,7 @@ using namespace Cantera; -typedef SharedCabinet ThermoCabinet; +typedef Cabinet ThermoCabinet; template<> ThermoCabinet* ThermoCabinet::s_storage; // defined in ct.cpp diff --git a/src/fortran/fct.cpp b/src/fortran/fct.cpp index 269a552d7e..aef8264d33 100644 --- a/src/fortran/fct.cpp +++ b/src/fortran/fct.cpp @@ -25,9 +25,9 @@ using namespace Cantera; -typedef SharedCabinet ThermoCabinet; -typedef SharedCabinet KineticsCabinet; -typedef SharedCabinet TransportCabinet; +typedef Cabinet ThermoCabinet; +typedef Cabinet KineticsCabinet; +typedef Cabinet TransportCabinet; typedef integer status_t;