From 86e91ab06a044b3b68166788d83904bc88d9fdd8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:58:31 +0300 Subject: [PATCH 1/5] #522 - core: replace Obj with standard smart pointer Obj replaced to unique_ptr and shared ptr. --- api/c/indigo/src/indigo_match.cpp | 4 +- api/c/indigo/src/indigo_match.h | 11 +- bingo/bingo-core-c/src/bingo_core_c.cpp | 17 +- .../bingo-core-c/src/bingo_core_c_internal.h | 25 ++- bingo/bingo-core-c/src/mango_core_c.cpp | 18 +- bingo/bingo-core-c/src/ringo_core_c.cpp | 2 +- bingo/bingo-core/src/core/bingo_context.h | 10 + bingo/bingo-core/src/core/mango_matchers.h | 11 +- .../src/core/mango_substructure.cpp | 2 +- .../oracle/src/oracle/bingo_fingerprints.cpp | 8 +- bingo/oracle/src/oracle/bingo_fingerprints.h | 15 +- .../oracle/src/oracle/mango_shadow_table.cpp | 4 +- bingo/oracle/src/oracle/mango_shadow_table.h | 11 +- bingo/oracle/src/oracle/rowid_saver.cpp | 2 +- bingo/oracle/src/oracle/rowid_saver.h | 13 +- .../base_cpp/common_exceptions_impl.cpp | 2 - core/indigo-core/common/base_cpp/obj.h | 191 ------------------ .../layout/molecule_layout_graph.h | 5 +- .../src/molecule_layout_graph_assign.cpp | 6 +- .../src/molecule_layout_graph_refine.cpp | 1 - core/indigo-core/molecule/cmf_loader.h | 7 +- core/indigo-core/molecule/cmf_saver.h | 7 +- .../molecule/molecule_arom_match.h | 2 +- .../molecule/molecule_electrons_localizer.h | 14 +- .../molecule/molecule_exact_matcher.h | 11 +- .../molecule_exact_substructure_matcher.h | 16 +- .../molecule/molecule_fingerprint.h | 7 +- .../molecule/molecule_pi_systems_matcher.h | 15 +- .../molecule/molecule_substructure_matcher.h | 13 +- core/indigo-core/molecule/molecule_tautomer.h | 7 +- .../molecule/molecule_tautomer_matcher.h | 6 +- .../molecule_tautomer_substructure_matcher.h | 7 +- core/indigo-core/molecule/rdf_loader.h | 12 +- core/indigo-core/molecule/src/cmf_loader.cpp | 6 +- core/indigo-core/molecule/src/cmf_saver.cpp | 6 +- .../molecule/src/inchi_wrapper.cpp | 8 +- .../molecule/src/molecule_arom_match.cpp | 13 +- .../src/molecule_electrons_localizer.cpp | 2 +- .../molecule/src/molecule_exact_matcher.cpp | 8 +- .../molecule_exact_substructure_matcher.cpp | 8 +- .../molecule/src/molecule_fingerprint.cpp | 11 +- .../src/molecule_pi_systems_matcher.cpp | 6 +- .../src/molecule_substructure_matcher.cpp | 24 +-- .../molecule/src/molecule_tautomer_match.cpp | 4 +- .../src/molecule_tautomer_matcher.cpp | 6 +- ...molecule_tautomer_substructure_matcher.cpp | 10 +- .../base_reaction_substructure_matcher.h | 3 +- core/indigo-core/reaction/crf_loader.h | 5 +- core/indigo-core/reaction/crf_saver.h | 5 +- .../reaction/reaction_enumerator_state.h | 14 +- .../reaction/reaction_substructure_matcher.h | 1 - .../base_reaction_substructure_matcher.cpp | 8 +- core/indigo-core/reaction/src/crf_loader.cpp | 12 +- core/indigo-core/reaction/src/crf_saver.cpp | 20 +- .../src/reaction_enumerator_state.cpp | 8 +- 55 files changed, 301 insertions(+), 369 deletions(-) delete mode 100644 core/indigo-core/common/base_cpp/obj.h diff --git a/api/c/indigo/src/indigo_match.cpp b/api/c/indigo/src/indigo_match.cpp index 3f75efed4c..b9efd44fa3 100644 --- a/api/c/indigo/src/indigo_match.cpp +++ b/api/c/indigo/src/indigo_match.cpp @@ -705,7 +705,7 @@ bool IndigoMoleculeSubstructureMatcher::findTautomerMatch(QueryMolecule& query, if (tau_matcher.get() == 0) { bool substructure = true; - tau_matcher.create(*target_prepared, substructure); + tau_matcher = std::make_unique(*target_prepared, substructure); } tau_matcher->setRulesList(&tautomer_rules); @@ -903,7 +903,7 @@ CEXPORT int indigoMatch(int target_matcher, int query) } if (matcher.matcher.get() == 0) - matcher.matcher.create(matcher.target); + matcher.matcher = std::make_unique(matcher.target); matcher.matcher->use_daylight_aam_mode = matcher.daylight_aam; matcher.matcher->setQuery(qrxn); diff --git a/api/c/indigo/src/indigo_match.h b/api/c/indigo/src/indigo_match.h index 637ce72311..8e5036646a 100644 --- a/api/c/indigo/src/indigo_match.h +++ b/api/c/indigo/src/indigo_match.h @@ -27,6 +27,13 @@ #include "reaction/reaction.h" #include "reaction/reaction_substructure_matcher.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + class IndigoQueryMolecule; #ifdef _WIN32 @@ -130,7 +137,7 @@ class DLLEXPORT IndigoMoleculeSubstructureMatcher : public IndigoObject Molecule& target; Molecule moleculeFound; - Obj tau_matcher; + std::unique_ptr tau_matcher; IndigoTautomerParams tau_params; bool findTautomerMatch(QueryMolecule& query, PtrArray& tautomer_rules, Array& mapping_out); @@ -159,7 +166,7 @@ class DLLEXPORT IndigoReactionSubstructureMatcher : public IndigoObject Reaction target; bool daylight_aam; - Obj matcher; + std::unique_ptr matcher; ObjArray> mappings; Array mol_mapping; }; diff --git a/bingo/bingo-core-c/src/bingo_core_c.cpp b/bingo/bingo-core-c/src/bingo_core_c.cpp index 60b48b79f3..3f65e04089 100644 --- a/bingo/bingo-core-c/src/bingo_core_c.cpp +++ b/bingo/bingo-core-c/src/bingo_core_c.cpp @@ -390,8 +390,8 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str) self.import_properties.free(); self.import_columns.free(); - self.import_properties.create(); - self.import_columns.create(); + self.import_properties = std::make_unique(); + self.import_columns = std::make_unique(); scanner.skipSpace(); @@ -486,8 +486,8 @@ CEXPORT const char* bingoImportGetPropertyValue(int idx) void BingoCore::bingoSDFImportOpen(const char* file_name) { self.bingoSDFImportClose(); - self.file_scanner.create(file_name); - self.sdf_loader.create(self.file_scanner.ref()); + self.file_scanner = std::make_unique(file_name); + self.sdf_loader = std::make_unique(self.file_scanner.ref()); } CEXPORT int bingoSDFImportOpen(const char* file_name) @@ -557,8 +557,8 @@ CEXPORT const char* bingoSDFImportGetProperty(const char* param_name) void BingoCore::bingoRDFImportOpen(const char* file_name) { self.bingoRDFImportClose(); - self.file_scanner.create(file_name); - self.rdf_loader.create(self.file_scanner.ref()); + self.file_scanner = std::make_unique(file_name); + self.rdf_loader = std::make_unique(self.file_scanner.ref()); } CEXPORT int bingoRDFImportOpen(const char* file_name) @@ -805,7 +805,7 @@ int BingoCore::bingoIndexBegin() _bingoIndexEnd(self); - self.index_record_data.create(); + self.index_record_data = std::make_unique>(); return 1; } @@ -830,8 +830,7 @@ CEXPORT int bingoIndexSetSkipFP(bool skip) void BingoCore::bingoSMILESImportOpen(const char* file_name) { - self.file_scanner.free(); - self.file_scanner.create(file_name); + self.file_scanner = std::make_unique(file_name); // detect if input is gzipped byte magic[2]; diff --git a/bingo/bingo-core-c/src/bingo_core_c_internal.h b/bingo/bingo-core-c/src/bingo_core_c_internal.h index ec72202da3..9d2a0a7156 100644 --- a/bingo/bingo-core-c/src/bingo_core_c_internal.h +++ b/bingo/bingo-core-c/src/bingo_core_c_internal.h @@ -44,6 +44,11 @@ #include "bingo_core_c.h" #include "bingo_core_c_parallel.h" +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { class GZipScanner; @@ -149,12 +154,12 @@ namespace indigo MangoContext* mango_context; RingoContext* ringo_context; - Obj import_properties; - Obj import_columns; + std::unique_ptr import_properties; + std::unique_ptr import_columns; - Obj file_scanner; - Obj sdf_loader; - Obj rdf_loader; + std::unique_ptr file_scanner; + std::unique_ptr sdf_loader; + std::unique_ptr rdf_loader; std::unique_ptr gz_scanner; Scanner* smiles_scanner; @@ -164,11 +169,11 @@ namespace indigo MangoIndex* mango_index; RingoIndex* ringo_index; - Obj> index_record_data; + std::unique_ptr> index_record_data; int index_record_data_id; - Obj single_mango_index; - Obj single_ringo_index; + std::unique_ptr single_mango_index; + std::unique_ptr single_ringo_index; std::unique_ptr parallel_indexing_dispatcher; @@ -359,4 +364,8 @@ namespace indigo } // namespace bingo_core } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif // __bingo_core_c_h___ diff --git a/bingo/bingo-core-c/src/mango_core_c.cpp b/bingo/bingo-core-c/src/mango_core_c.cpp index b472ddb248..13daa9125d 100644 --- a/bingo/bingo-core-c/src/mango_core_c.cpp +++ b/bingo/bingo-core-c/src/mango_core_c.cpp @@ -37,6 +37,11 @@ using namespace indigo; using namespace indigo::bingo_core; +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + int BingoCore::mangoIndexProcessSingleRecord() { BufferScanner scanner(self.index_record_data.ref()); @@ -49,7 +54,7 @@ int BingoCore::mangoIndexProcessSingleRecord() { if (self.single_mango_index.get() == NULL) { - self.single_mango_index.create(); + self.single_mango_index = std::make_unique(); self.single_mango_index->init(*self.bingo_context); self.single_mango_index->skip_calculate_fp = self.skip_calculate_fp; } @@ -464,12 +469,11 @@ int BingoCore::mangoMatchTargetBinary(const char* target_bin, int target_bin_len TRY_READ_TARGET_MOL { BufferScanner scanner(target_bin, target_bin_len); - BufferScanner* xyz_scanner = 0; - Obj xyz_scanner_obj; + + std::unique_ptr xyz_scanner; if (target_xyz_len != 0) { - xyz_scanner_obj.create(target_xyz, target_xyz_len); - xyz_scanner = xyz_scanner_obj.get(); + xyz_scanner = std::make_unique(target_xyz, target_xyz_len); } if (self.mango_search_type == BingoCore::_SUBSTRUCTRE) @@ -1136,3 +1140,7 @@ CEXPORT const char* mangoStandardize(const char* molecule, int molecule_len, con } BINGO_END(0, 0); } + +#ifdef _WIN32 +#pragma warning(pop) +#endif diff --git a/bingo/bingo-core-c/src/ringo_core_c.cpp b/bingo/bingo-core-c/src/ringo_core_c.cpp index 072a1c47c3..ef0e4eb810 100644 --- a/bingo/bingo-core-c/src/ringo_core_c.cpp +++ b/bingo/bingo-core-c/src/ringo_core_c.cpp @@ -47,7 +47,7 @@ int BingoCore::ringoIndexProcessSingleRecord() { if (self.single_ringo_index.get() == NULL) { - self.single_ringo_index.create(); + self.single_ringo_index = std::make_unique(); self.single_ringo_index->init(*self.bingo_context); self.single_ringo_index->skip_calculate_fp = self.skip_calculate_fp; } diff --git a/bingo/bingo-core/src/core/bingo_context.h b/bingo/bingo-core/src/core/bingo_context.h index 165481209e..07e59020ec 100644 --- a/bingo/bingo-core/src/core/bingo_context.h +++ b/bingo/bingo-core/src/core/bingo_context.h @@ -20,6 +20,7 @@ #define __bingo_context__ #include +#include #include "base_cpp/nullable.h" #include "bingo_version.h" @@ -27,6 +28,11 @@ #include "molecule/molecule_fingerprint.h" #include "molecule/molecule_tautomer.h" +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + // extern const char *bingo_version_string; namespace indigo @@ -120,4 +126,8 @@ void bingoGetTauCondition(const char* list_ptr, int& aromaticity, indigo::Array< void bingoGetName(indigo::Scanner& scanner, indigo::Array& result); +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/bingo/bingo-core/src/core/mango_matchers.h b/bingo/bingo-core/src/core/mango_matchers.h index 1946a8f3fe..5d319ef9b4 100644 --- a/bingo/bingo-core/src/core/mango_matchers.h +++ b/bingo/bingo-core/src/core/mango_matchers.h @@ -29,6 +29,11 @@ #include "molecule/query_molecule.h" #include +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -88,7 +93,7 @@ namespace indigo ObjArray> _fmcache; // cmf loader for delayed xyz loading - Obj cmf_loader; + std::unique_ptr cmf_loader; bool _query_has_stereocare_bonds; bool _query_has_stereocenters; @@ -325,4 +330,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/bingo/bingo-core/src/core/mango_substructure.cpp b/bingo/bingo-core/src/core/mango_substructure.cpp index bb5f7c7a80..73a9aebffb 100644 --- a/bingo/bingo-core/src/core/mango_substructure.cpp +++ b/bingo/bingo-core/src/core/mango_substructure.cpp @@ -318,7 +318,7 @@ bool MangoSubstructure::matchBinary(Scanner& scanner, Scanner* xyz_scanner) profTimerStart(tcmf, "match.cmf"); cmf_loader.free(); - cmf_loader.create(_context.cmf_dict, scanner); + cmf_loader = std::make_unique(_context.cmf_dict, scanner); if (!_query_has_stereocare_bonds) cmf_loader->skip_cistrans = true; diff --git a/bingo/oracle/src/oracle/bingo_fingerprints.cpp b/bingo/oracle/src/oracle/bingo_fingerprints.cpp index bbe3a8d67e..4f0108d6cb 100644 --- a/bingo/oracle/src/oracle/bingo_fingerprints.cpp +++ b/bingo/oracle/src/oracle/bingo_fingerprints.cpp @@ -274,8 +274,8 @@ bool BingoFingerprints::screenPart_Init(OracleEnv& env, Screening& screening) screening.block = &_all_blocks[screening.part]; - screening.statement.create(env); - screening.bits_lob.create(env); + screening.statement = std::make_unique(env); + screening.bits_lob = std::make_unique(env); screening.statement->append("SELECT bits FROM %s WHERE part = :part", _table_name.ptr()); screening.statement->prepare(); screening.statement->bindIntByName(":part", &screening.part); @@ -461,8 +461,8 @@ bool BingoFingerprints::countOnes_Init(OracleEnv& env, Screening& screening) if (screening.part >= _all_blocks.size()) return false; - screening.statement.create(env); - screening.bits_lob.create(env); + screening.statement = std::make_unique(env); + screening.bits_lob = std::make_unique(env); screening.statement->append("SELECT bits FROM %s WHERE part = :part", _table_name.ptr()); screening.statement->prepare(); screening.statement->bindIntByName(":part", &screening.part); diff --git a/bingo/oracle/src/oracle/bingo_fingerprints.h b/bingo/oracle/src/oracle/bingo_fingerprints.h index 025c090514..0e90635ecc 100644 --- a/bingo/oracle/src/oracle/bingo_fingerprints.h +++ b/bingo/oracle/src/oracle/bingo_fingerprints.h @@ -25,6 +25,13 @@ #include "base_cpp/tlscont.h" #include "core/bingo_context.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { class OracleEnv; @@ -73,8 +80,8 @@ namespace indigo void* data; - Obj statement; - Obj bits_lob; + std::unique_ptr statement; + std::unique_ptr bits_lob; Block* block; int query_bit_idx; }; @@ -149,4 +156,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/bingo/oracle/src/oracle/mango_shadow_table.cpp b/bingo/oracle/src/oracle/mango_shadow_table.cpp index 49fdadbd6e..3b79f9aa59 100644 --- a/bingo/oracle/src/oracle/mango_shadow_table.cpp +++ b/bingo/oracle/src/oracle/mango_shadow_table.cpp @@ -60,7 +60,7 @@ void MangoShadowTable::addMolecule(OracleEnv& env, const char* rowid, int blockn if (_main_table_statement.get() == 0) { - _main_table_statement.create(env); + _main_table_statement = std::make_unique(env); _main_table_statement_count = 0; /* @@ -120,7 +120,7 @@ void MangoShadowTable::addMolecule(OracleEnv& env, const char* rowid, int blockn if (_components_table_statement.get() == 0) { - _components_table_statement.create(env); + _components_table_statement = std::make_unique(env); _components_table_statement->append("INSERT %s INTO %s VALUES (:rid, :hash, :count)", append ? "/*+ APPEND_VALUES */" : "", _components_table_name.ptr()); _components_table_statement_count = 0; diff --git a/bingo/oracle/src/oracle/mango_shadow_table.h b/bingo/oracle/src/oracle/mango_shadow_table.h index c05397f098..cf440390a5 100644 --- a/bingo/oracle/src/oracle/mango_shadow_table.h +++ b/bingo/oracle/src/oracle/mango_shadow_table.h @@ -25,6 +25,13 @@ #include "oracle/bingo_fetch_engine.h" #include "oracle/ora_wrap.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -62,8 +69,8 @@ namespace indigo void _flushMain(OracleEnv& env); void _flushComponents(OracleEnv& env); - Obj _main_table_statement; - Obj _components_table_statement; + std::unique_ptr _main_table_statement; + std::unique_ptr _components_table_statement; int _main_table_statement_count; int _components_table_statement_count; diff --git a/bingo/oracle/src/oracle/rowid_saver.cpp b/bingo/oracle/src/oracle/rowid_saver.cpp index 5e5ffd223d..50d84178cb 100644 --- a/bingo/oracle/src/oracle/rowid_saver.cpp +++ b/bingo/oracle/src/oracle/rowid_saver.cpp @@ -33,7 +33,7 @@ RowIDSaver::RowIDSaver(LzwDict& NewDict, Output& NewOut) if (!NewDict.isInitialized()) NewDict.init(ROW_ID_ALPHABET_SIZE, ROW_ID_BIT_CODE_SIZE); - _encoder_obj.create(NewDict, NewOut); + _encoder_obj = std::make_unique(NewDict, NewOut); _encoder = _encoder_obj.get(); }; diff --git a/bingo/oracle/src/oracle/rowid_saver.h b/bingo/oracle/src/oracle/rowid_saver.h index 4ce0fa1f46..8bfe9b0196 100644 --- a/bingo/oracle/src/oracle/rowid_saver.h +++ b/bingo/oracle/src/oracle/rowid_saver.h @@ -26,6 +26,13 @@ #include "base_cpp/obj.h" #include "oracle/rowid_symbol_codes.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { class Output; @@ -45,7 +52,7 @@ namespace indigo void _encode(int NextSymbol); - Obj _encoder_obj; + std::unique_ptr _encoder_obj; LzwEncoder* _encoder; @@ -55,6 +62,10 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif /* __rowid_saver_h__ */ /* END OF 'ROWID_SAVER.H' FILE */ diff --git a/core/indigo-core/common/base_cpp/common_exceptions_impl.cpp b/core/indigo-core/common/base_cpp/common_exceptions_impl.cpp index e54712fe39..48bcdbe93a 100644 --- a/core/indigo-core/common/base_cpp/common_exceptions_impl.cpp +++ b/core/indigo-core/common/base_cpp/common_exceptions_impl.cpp @@ -20,7 +20,6 @@ #include "base_cpp/cyclic_array.h" #include "base_cpp/d_bitset.h" #include "base_cpp/nullable.h" -#include "base_cpp/obj.h" #include "base_cpp/pool.h" #include "base_cpp/ptr_array.h" #include "base_cpp/ptr_pool.h" @@ -32,7 +31,6 @@ IMPL_EXCEPTION(indigo, NullableError, "Nullable"); IMPL_EXCEPTION(indigo, ArrayError, "array"); IMPL_EXCEPTION(indigo, CyclicArrayError, "cyclic array"); IMPL_EXCEPTION(indigo, DbitsetError, "Dynamic bitset"); -IMPL_EXCEPTION(indigo, ObjError, "obj"); IMPL_EXCEPTION(indigo, PoolError, "pool"); IMPL_EXCEPTION(indigo, PtrArrayError, "ptr array"); IMPL_EXCEPTION(indigo, PtrPoolError, "ptr pool"); diff --git a/core/indigo-core/common/base_cpp/obj.h b/core/indigo-core/common/base_cpp/obj.h deleted file mode 100644 index 3a3fff1301..0000000000 --- a/core/indigo-core/common/base_cpp/obj.h +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** - * Copyright (C) from 2009 to Present EPAM Systems. - * - * This file is part of Indigo toolkit. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -#ifndef __obj_h__ -#define __obj_h__ - -#include "base_cpp/exception.h" - -namespace indigo -{ - - DECL_EXCEPTION(ObjError); - - // Reusable storage for object - template - class Obj - { - public: - Obj() : _initialized(false) - { - } - - ~Obj() - { - free(); - } - - T* get() const - { - if (!_initialized) - return 0; - return _ptr(); - } - - T* operator->() const - { - if (!_initialized) - throw Error("no object"); - - return _ptr(); - } - - T& ref() const - { - if (!_initialized) - throw Error("no object"); - - return *_ptr(); - } - - T& create() - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a); - _initialized = true; - return *_ptr(); - } - - template - T& recreate(A& a) - { - free(); - return create(a); - } - - template - T& create(const A& a) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a, B& b) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a, b); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a, B* b) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a, b); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a, B& b, C* c) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a, b, c); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a, B& b, C& c) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a, b, c); - _initialized = true; - return *_ptr(); - } - - template - T& create(A& a, B* b, C& c) - { - if (_initialized) - throw Error("create(): already have object"); - - new (_storage) T(a, b, c); - _initialized = true; - return *_ptr(); - } - - void free() - { - if (_initialized) - { - _ptr()->~T(); - _initialized = false; - } - } - - inline void clear() - { - free(); - } - - DECL_TPL_ERROR(ObjError); - - protected: - T* _ptr() const - { - return (T*)_storage; - } - - char _storage[sizeof(T)]; - bool _initialized; - - private: - Obj(const Obj&); // no implicit copy - }; - -} // namespace indigo - -#endif diff --git a/core/indigo-core/layout/molecule_layout_graph.h b/core/indigo-core/layout/molecule_layout_graph.h index 2429f41a93..6b954b9eff 100644 --- a/core/indigo-core/layout/molecule_layout_graph.h +++ b/core/indigo-core/layout/molecule_layout_graph.h @@ -20,7 +20,6 @@ #define __molecule_layout_graph_h__ #include "base_cpp/cancellation_handler.h" -#include "base_cpp/obj.h" #include "base_cpp/obj_array.h" #include "base_cpp/tlscont.h" #include "graph/filter.h" @@ -29,6 +28,8 @@ #include "math/algebra.h" #include "molecule/molecule.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -186,7 +187,7 @@ namespace indigo int _n_fixed; // Outline of the graph (from pattern) - Obj> _outline; + std::unique_ptr> _outline; BaseMolecule* _molecule; const int* _molecule_edge_mapping; diff --git a/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp b/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp index 0b30e3ef2a..094e7ff1e4 100644 --- a/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp +++ b/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp @@ -252,7 +252,7 @@ int MoleculeLayoutGraphSimple::_pattern_embedding(Graph& subgraph, Graph& superg layout_graph._first_vertex_idx = layout_graph.vertexBegin(); if (layout_graph._outline.get() == 0) - layout_graph._outline.create(); + layout_graph._outline = std::make_unique>(); layout_graph._outline->copy(pattern_graph.getOutline()); return 0; @@ -544,8 +544,8 @@ void MoleculeLayoutGraph::_buildOutline(void) pos_i = getPos(i); - if (_outline.get() == 0) - _outline.create(); + if (_outline.get() == nullptr) + _outline = std::make_unique>(); else _outline->clear(); diff --git a/core/indigo-core/layout/src/molecule_layout_graph_refine.cpp b/core/indigo-core/layout/src/molecule_layout_graph_refine.cpp index f2c44337c3..5fbe949e85 100644 --- a/core/indigo-core/layout/src/molecule_layout_graph_refine.cpp +++ b/core/indigo-core/layout/src/molecule_layout_graph_refine.cpp @@ -16,7 +16,6 @@ * limitations under the License. ***************************************************************************/ -#include "base_cpp/obj.h" #include "base_cpp/red_black.h" #include "graph/biconnected_decomposer.h" #include "graph/graph_subchain_enumerator.h" diff --git a/core/indigo-core/molecule/cmf_loader.h b/core/indigo-core/molecule/cmf_loader.h index 29912244d1..9b64eaf729 100644 --- a/core/indigo-core/molecule/cmf_loader.h +++ b/core/indigo-core/molecule/cmf_loader.h @@ -20,11 +20,12 @@ #define __cmf_loader_h__ #include "base_cpp/bitinworker.h" -#include "base_cpp/obj.h" #include "lzw/lzw_decoder.h" #include "lzw/lzw_dictionary.h" #include "molecule/cmf_saver.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -143,9 +144,9 @@ namespace indigo Scanner* _scanner; - Obj _decoder_obj; + std::unique_ptr _decoder_obj; LzwDecoder* _ext_decoder; - Obj _lzw_scanner; + std::unique_ptr _lzw_scanner; TL_CP_DECL(Array<_AtomDesc>, _atoms); TL_CP_DECL(Array<_BondDesc>, _bonds); diff --git a/core/indigo-core/molecule/cmf_saver.h b/core/indigo-core/molecule/cmf_saver.h index eccea158be..98432e9dbe 100644 --- a/core/indigo-core/molecule/cmf_saver.h +++ b/core/indigo-core/molecule/cmf_saver.h @@ -19,11 +19,12 @@ #ifndef __cmf_saver_h__ #define __cmf_saver_h__ -#include "base_cpp/obj.h" #include "lzw/lzw_encoder.h" #include "math/algebra.h" #include "molecule/base_molecule.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -104,9 +105,9 @@ namespace indigo TL_CP_DECL(Array, _atom_sequence); Output* _output; - Obj _encoder_obj; + std::unique_ptr _encoder_obj; LzwEncoder* _ext_encoder; - Obj _encoder_output_obj; + std::unique_ptr _encoder_output_obj; Molecule* _mol; diff --git a/core/indigo-core/molecule/molecule_arom_match.h b/core/indigo-core/molecule/molecule_arom_match.h index 92b2c781a5..92ee0324fc 100644 --- a/core/indigo-core/molecule/molecule_arom_match.h +++ b/core/indigo-core/molecule/molecule_arom_match.h @@ -52,7 +52,7 @@ namespace indigo // Check if query bond can be aromatic if 'aromatic' is true and // nonaromatic otherwise. - bool canFixQueryBond(int query_edge_idx, bool aromatic); + bool canFixQueryBond(int query_edge_idx, bool aromatic) const; // Fix query bond to aromatic or nonaromatic state void fixQueryBond(int query_edge_idx, bool aromatic); diff --git a/core/indigo-core/molecule/molecule_electrons_localizer.h b/core/indigo-core/molecule/molecule_electrons_localizer.h index 64b103a6ac..76279425d6 100644 --- a/core/indigo-core/molecule/molecule_electrons_localizer.h +++ b/core/indigo-core/molecule/molecule_electrons_localizer.h @@ -21,10 +21,16 @@ #include "base_cpp/array.h" #include "base_cpp/exception.h" -#include "base_cpp/obj.h" #include "base_cpp/tlscont.h" #include "graph/graph_constrained_bmatching_finder.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -146,7 +152,7 @@ namespace indigo int _getAtomCharge(int atom) const; void _getAtomConnAndLonepairs(int atom, int& added_conn, int& lonepairs) const; - Obj _finder; + std::unique_ptr _finder; Molecule& _skeleton; // Localization parameters @@ -212,4 +218,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif // __molecule_electrons_localizer__ diff --git a/core/indigo-core/molecule/molecule_exact_matcher.h b/core/indigo-core/molecule/molecule_exact_matcher.h index 50c6882f0e..9a8b0645cc 100644 --- a/core/indigo-core/molecule/molecule_exact_matcher.h +++ b/core/indigo-core/molecule/molecule_exact_matcher.h @@ -19,7 +19,6 @@ #ifndef __molecule_exact_matcher__ #define __molecule_exact_matcher__ -#include "base_cpp/obj.h" #include "base_cpp/scanner.h" #include "graph/embedding_enumerator.h" #include "graph/filter.h" @@ -31,6 +30,8 @@ #include "molecule/molecule_stereocenters.h" #include "molecule/molecule_substructure_matcher.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -81,8 +82,8 @@ namespace indigo BaseMolecule& _query; BaseMolecule& _target; EmbeddingEnumerator _ee; - Obj _query_decomposer; - Obj _target_decomposer; + std::unique_ptr _query_decomposer; + std::unique_ptr _target_decomposer; struct _MatchToken { @@ -104,4 +105,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/core/indigo-core/molecule/molecule_exact_substructure_matcher.h b/core/indigo-core/molecule/molecule_exact_substructure_matcher.h index 4bfd2c8f73..535d226cec 100644 --- a/core/indigo-core/molecule/molecule_exact_substructure_matcher.h +++ b/core/indigo-core/molecule/molecule_exact_substructure_matcher.h @@ -19,10 +19,16 @@ #ifndef __molecule_exact_substructure_matcher__ #define __molecule_exact_substructure_matcher__ -#include "base_cpp/obj.h" #include "graph/embedding_enumerator.h" #include "graph/graph_decomposer.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -49,8 +55,8 @@ namespace indigo Molecule& _query; Molecule& _target; EmbeddingEnumerator _ee; - Obj _query_decomposer; - Obj _target_decomposer; + std::unique_ptr _query_decomposer; + std::unique_ptr _target_decomposer; struct _MatchToken { @@ -72,4 +78,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif diff --git a/core/indigo-core/molecule/molecule_fingerprint.h b/core/indigo-core/molecule/molecule_fingerprint.h index e32dd31766..867241dff0 100644 --- a/core/indigo-core/molecule/molecule_fingerprint.h +++ b/core/indigo-core/molecule/molecule_fingerprint.h @@ -23,10 +23,11 @@ #include #include "base_cpp/cancellation_handler.h" -#include "base_cpp/obj.h" #include "base_cpp/tlscont.h" #include "graph/subgraph_hash.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -179,7 +180,7 @@ namespace indigo const MoleculeFingerprintParameters& _parameters; // these parameters are indirectly passed to the callbacks - TautomerSuperStructure* _tau_super_structure; + std::unique_ptr _tau_super_structure; bool _is_cycle; struct HashBits @@ -197,7 +198,7 @@ namespace indigo void _addOrdHashBits(dword hash, int bits_per_fragment); - Obj subgraph_hash; + std::unique_ptr subgraph_hash; CP_DECL; TL_CP_DECL(Array, _total_fingerprint); diff --git a/core/indigo-core/molecule/molecule_pi_systems_matcher.h b/core/indigo-core/molecule/molecule_pi_systems_matcher.h index 2a9ac589f5..149753d90c 100644 --- a/core/indigo-core/molecule/molecule_pi_systems_matcher.h +++ b/core/indigo-core/molecule/molecule_pi_systems_matcher.h @@ -28,6 +28,13 @@ #include "molecule/molecule_electrons_localizer.h" #include "molecule/query_molecule.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { class Molecule; @@ -84,7 +91,7 @@ namespace indigo }; Molecule& _target; - Obj _decomposer; + std::unique_ptr _decomposer; CP_DECL; TL_CP_DECL(Array, _atom_pi_system_idx); @@ -93,7 +100,7 @@ namespace indigo { Molecule pi_system; Array inv_mapping, mapping; - Obj localizer; + std::unique_ptr localizer; struct Localizations { @@ -112,4 +119,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif // __molecule_pi_systems_matcher__ diff --git a/core/indigo-core/molecule/molecule_substructure_matcher.h b/core/indigo-core/molecule/molecule_substructure_matcher.h index 63de81fef5..6f66aa6092 100644 --- a/core/indigo-core/molecule/molecule_substructure_matcher.h +++ b/core/indigo-core/molecule/molecule_substructure_matcher.h @@ -19,7 +19,6 @@ #ifndef __molecule_substructure_matcher__ #define __molecule_substructure_matcher__ -#include "base_cpp/obj.h" #include "graph/embedding_enumerator.h" #include "graph/embeddings_storage.h" #include "molecule/molecule.h" @@ -148,7 +147,7 @@ namespace indigo static bool matchQueryAtom(QueryMolecule::Atom* query, BaseMolecule& target, int super_idx, FragmentMatchCache* fmcache, dword flags); - static bool matchQueryBond(QueryMolecule::Bond* query, BaseMolecule& target, int sub_idx, int super_idx, AromaticityMatcher* am, dword flags); + static bool matchQueryBond(QueryMolecule::Bond* query, BaseMolecule& target, int sub_idx, int super_idx, const AromaticityMatcher* am, dword flags); static void makeTransposition(BaseMolecule& mol, Array& transposition); @@ -200,18 +199,18 @@ namespace indigo const MoleculeAtomNeighbourhoodCounters *_query_nei_counters, *_target_nei_counters; - Obj _ee; + std::unique_ptr _ee; std::unique_ptr _markush; // Because storage can be big it is not stored into TL_CP_*** // It can be stored as TL_CP_*** if memory allocations will // be critical - Obj _embeddings_storage; + std::unique_ptr _embeddings_storage; - Obj _3d_constraints_checker; - Obj _am; - Obj _pi_systems_matcher; + std::unique_ptr _3d_constraints_checker; + std::unique_ptr _am; + std::unique_ptr _pi_systems_matcher; bool _h_unfold; // implicit target hydrogens unfolded diff --git a/core/indigo-core/molecule/molecule_tautomer.h b/core/indigo-core/molecule/molecule_tautomer.h index ac2540d614..abae0a916e 100644 --- a/core/indigo-core/molecule/molecule_tautomer.h +++ b/core/indigo-core/molecule/molecule_tautomer.h @@ -20,12 +20,13 @@ #define __molecule_tautomer_h__ #include "base_cpp/array.h" -#include "base_cpp/obj.h" #include "base_cpp/tlscont.h" #include "graph/graph_decomposer.h" #include "molecule/molecule.h" #include "molecule/molecule_dearom.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -105,8 +106,8 @@ namespace indigo TL_CP_DECL(Array, n1); TL_CP_DECL(Array, n2); - Obj dearomatizer; - Obj dearomatizationMatcher; + std::unique_ptr dearomatizer; + std::unique_ptr dearomatizationMatcher; }; class TautomerMatcher diff --git a/core/indigo-core/molecule/molecule_tautomer_matcher.h b/core/indigo-core/molecule/molecule_tautomer_matcher.h index 827bbee4bf..e7da6c6890 100644 --- a/core/indigo-core/molecule/molecule_tautomer_matcher.h +++ b/core/indigo-core/molecule/molecule_tautomer_matcher.h @@ -74,11 +74,11 @@ namespace indigo Molecule& _target_src; std::unique_ptr _query; - Obj _target; + std::unique_ptr _target; BaseMolecule* _supermol; - Obj _query_decomposer; - Obj _target_decomposer; + std::unique_ptr _query_decomposer; + std::unique_ptr _target_decomposer; }; } // namespace indigo diff --git a/core/indigo-core/molecule/molecule_tautomer_substructure_matcher.h b/core/indigo-core/molecule/molecule_tautomer_substructure_matcher.h index fd8aab0461..f2143e54d6 100644 --- a/core/indigo-core/molecule/molecule_tautomer_substructure_matcher.h +++ b/core/indigo-core/molecule/molecule_tautomer_substructure_matcher.h @@ -19,7 +19,6 @@ #ifndef __molecule_tautomer_substructure_matcher__ #define __molecule_tautomer_substructure_matcher__ -#include "base_cpp/obj.h" #include "graph/embedding_enumerator.h" #include "graph/embeddings_storage.h" #include "molecule/molecule.h" @@ -27,6 +26,8 @@ #include "molecule/molecule_tautomer.h" #include "molecule/molecule_tautomer_enumerator.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -77,12 +78,12 @@ namespace indigo QueryMolecule* _query; TautomerEnumerator _tautomerEnumerator; - Obj _ee; + std::unique_ptr _ee; // Because storage can be big it is not stored into TL_CP_*** // It can be stored as TL_CP_*** if memory allocations will // be critical - Obj _embeddings_storage; + std::unique_ptr _embeddings_storage; ObjArray _masks; CP_DECL; diff --git a/core/indigo-core/molecule/rdf_loader.h b/core/indigo-core/molecule/rdf_loader.h index 88c59292d9..8568a6a46a 100644 --- a/core/indigo-core/molecule/rdf_loader.h +++ b/core/indigo-core/molecule/rdf_loader.h @@ -19,10 +19,16 @@ #ifndef _RDF_LOADER_H__ #define _RDF_LOADER_H__ -#include "base_cpp/obj.h" #include "base_cpp/properties_map.h" #include "base_cpp/tlscont.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -96,4 +102,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif /* _RDF_READER_H */ diff --git a/core/indigo-core/molecule/src/cmf_loader.cpp b/core/indigo-core/molecule/src/cmf_loader.cpp index b76246a90a..af6f9ae970 100644 --- a/core/indigo-core/molecule/src/cmf_loader.cpp +++ b/core/indigo-core/molecule/src/cmf_loader.cpp @@ -33,8 +33,8 @@ CmfLoader::CmfLoader(LzwDict& dict, Scanner& scanner) TL_CP_GET(inv_bond_mapping_to_restore), TL_CP_GET(_atoms), TL_CP_GET(_bonds), TL_CP_GET(_pseudo_labels), TL_CP_GET(_attachments), TL_CP_GET(_sgroup_order) { _init(); - _decoder_obj.create(dict, scanner); - _lzw_scanner.create(_decoder_obj.ref()); + _decoder_obj = std::make_unique(dict, scanner); + _lzw_scanner = std::make_unique(*_decoder_obj); _scanner = _lzw_scanner.get(); } @@ -51,7 +51,7 @@ CmfLoader::CmfLoader(LzwDecoder& decoder) TL_CP_GET(inv_bond_mapping_to_restore), TL_CP_GET(_atoms), TL_CP_GET(_bonds), TL_CP_GET(_pseudo_labels), TL_CP_GET(_attachments), TL_CP_GET(_sgroup_order) { _init(); - _lzw_scanner.create(decoder); + _lzw_scanner = std::make_unique(decoder); _scanner = _lzw_scanner.get(); } diff --git a/core/indigo-core/molecule/src/cmf_saver.cpp b/core/indigo-core/molecule/src/cmf_saver.cpp index 89c91f3f86..7534c77b9c 100644 --- a/core/indigo-core/molecule/src/cmf_saver.cpp +++ b/core/indigo-core/molecule/src/cmf_saver.cpp @@ -39,8 +39,8 @@ CmfSaver::CmfSaver(LzwDict& dict, Output& output) : CP_INIT, TL_CP_GET(_atom_seq if (!dict.isInitialized()) dict.init(CMF_ALPHABET_SIZE, CMF_BIT_CODE_SIZE); - _encoder_obj.create(dict, output); - _encoder_output_obj.create(_encoder_obj.ref()); + _encoder_obj = std::make_unique(dict, output); + _encoder_output_obj = std::make_unique(*_encoder_obj); _output = _encoder_output_obj.get(); } @@ -48,7 +48,7 @@ CmfSaver::CmfSaver(LzwEncoder& encoder) : CP_INIT, TL_CP_GET(_atom_sequence) { _init(); _ext_encoder = &encoder; - _encoder_output_obj.create(encoder); + _encoder_output_obj = std::make_unique(encoder); _output = _encoder_output_obj.get(); } diff --git a/core/indigo-core/molecule/src/inchi_wrapper.cpp b/core/indigo-core/molecule/src/inchi_wrapper.cpp index bf18a36fcf..4ed85e5bce 100644 --- a/core/indigo-core/molecule/src/inchi_wrapper.cpp +++ b/core/indigo-core/molecule/src/inchi_wrapper.cpp @@ -21,7 +21,6 @@ #include "molecule/inchi_wrapper.h" -#include "base_cpp/obj.h" #include "molecule/elements.h" #include "molecule/molecule.h" #include "molecule/molecule_dearom.h" @@ -635,10 +634,11 @@ void InchiWrapper::saveMoleculeIntoInchi(Molecule& mol, Array& inchi) } Molecule* target = &mol; - Obj dearom; + // 2do: use unique_ptr instead of Obj + std::optional dearom; if (has_aromatic) { - dearom.create(); + dearom.emplace(); dearom->clone(mol, 0, 0); try { @@ -655,7 +655,7 @@ void InchiWrapper::saveMoleculeIntoInchi(Molecule& mol, Array& inchi) catch (DearomatizationException&) { } - target = dearom.get(); + target = &dearom.value(); } generateInchiInput(*target, input, atoms, stereo); diff --git a/core/indigo-core/molecule/src/molecule_arom_match.cpp b/core/indigo-core/molecule/src/molecule_arom_match.cpp index a323f78be0..c2c6f6b7c1 100644 --- a/core/indigo-core/molecule/src/molecule_arom_match.cpp +++ b/core/indigo-core/molecule/src/molecule_arom_match.cpp @@ -18,7 +18,6 @@ #include "molecule/molecule_arom_match.h" -#include "base_cpp/obj.h" #include "graph/filter.h" #include "graph/spanning_tree.h" #include "molecule/molecule_dearom.h" @@ -84,7 +83,7 @@ void AromaticityMatcher::validateQuery() } } -bool AromaticityMatcher::canFixQueryBond(int query_edge_idx, bool aromatic) +bool AromaticityMatcher::canFixQueryBond(int query_edge_idx, bool aromatic) const { // Check if bond is fixed then it aromatic state must be the same int _bond_state = _matching_edges_state[query_edge_idx]; @@ -264,8 +263,8 @@ bool AromaticityMatcher::match(int* core_sub, int* core_super) QS_DEF(DearomatizationsStorage, dearomatizations); // Dearomatizer and DearomatizationMatcher will be created on demand - Obj dearomatizer; - Obj dearomatizationMatcher; + std::unique_ptr dearomatizer; + std::unique_ptr dearomatizationMatcher; // Check edges for (int e = _submolecule->edgeBegin(); e != _submolecule->edgeEnd(); e = _submolecule->edgeNext(e)) @@ -312,11 +311,11 @@ bool AromaticityMatcher::match(int* core_sub, int* core_super) continue; // Find dearomatization - if (dearomatizer.get() == NULL) + if (dearomatizer.get() == nullptr) { - dearomatizer.create(*_submolecule, external_conn.ptr(), _arom_options); + dearomatizer = std::make_unique(*_submolecule, external_conn.ptr(), _arom_options); dearomatizer->enumerateDearomatizations(dearomatizations); - dearomatizationMatcher.create(dearomatizations, *_submolecule, external_conn.ptr()); + dearomatizationMatcher = std::make_unique(dearomatizations, *_submolecule, external_conn.ptr()); } // Fix bond diff --git a/core/indigo-core/molecule/src/molecule_electrons_localizer.cpp b/core/indigo-core/molecule/src/molecule_electrons_localizer.cpp index 8bfa306828..fb48df258c 100644 --- a/core/indigo-core/molecule/src/molecule_electrons_localizer.cpp +++ b/core/indigo-core/molecule/src/molecule_electrons_localizer.cpp @@ -136,7 +136,7 @@ void MoleculeElectronsLocalizer::_constructBMatchingFinder() set_per_set[_PRIMARY_LONEPAIRS_SET] = _SUM_LONEPAIRS_SET; set_per_set[_SECONDARY_LONEPAIRS_SET] = _SUM_LONEPAIRS_SET; - _finder.create(_extended_skeleton, nodes_per_set, &set_per_set); + _finder = std::make_unique(_extended_skeleton, nodes_per_set, &set_per_set); } void MoleculeElectronsLocalizer::_setupAtomProperties() diff --git a/core/indigo-core/molecule/src/molecule_exact_matcher.cpp b/core/indigo-core/molecule/src/molecule_exact_matcher.cpp index e8a0ab33ce..d6780af687 100644 --- a/core/indigo-core/molecule/src/molecule_exact_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_exact_matcher.cpp @@ -115,7 +115,7 @@ void MoleculeExactMatcher::_collectConnectedComponentsInfo() target_vertices_filter.init(_ee.getSupergraphMapping(), Filter::NEQ, EmbeddingEnumerator::IGNORE); // Target decomposition - _target_decomposer.create(_target); + _target_decomposer = std::make_unique(_target); _target_decomposer->decompose(&target_vertices_filter); // Query vertices filter initialization @@ -123,7 +123,7 @@ void MoleculeExactMatcher::_collectConnectedComponentsInfo() query_vertices_filter.init(_ee.getSubgraphMapping(), Filter::NEQ, EmbeddingEnumerator::IGNORE); // Query decomposition - _query_decomposer.create(_query); + _query_decomposer = std::make_unique(_query); _query_decomposer->decompose(&query_vertices_filter); } @@ -137,8 +137,8 @@ bool MoleculeExactMatcher::_matchAtoms(Graph& subgraph, Graph& supergraph, const if (!(flags & CONDITION_FRAGMENTS)) { - const GraphDecomposer& target_decomposer = self->_target_decomposer.ref(); - const GraphDecomposer& query_decomposer = self->_query_decomposer.ref(); + const GraphDecomposer& target_decomposer = *self->_target_decomposer; + const GraphDecomposer& query_decomposer = *self->_query_decomposer; int super_component = target_decomposer.getComponent(super_idx); int sub_component = query_decomposer.getComponent(sub_idx); diff --git a/core/indigo-core/molecule/src/molecule_exact_substructure_matcher.cpp b/core/indigo-core/molecule/src/molecule_exact_substructure_matcher.cpp index 5ce75a066e..0aeca83e3e 100644 --- a/core/indigo-core/molecule/src/molecule_exact_substructure_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_exact_substructure_matcher.cpp @@ -145,7 +145,7 @@ void MoleculeExactSubstructureMatcher::_collectConnectedComponentsInfo() target_vertices_filter.init(_ee.getSupergraphMapping(), Filter::NEQ, EmbeddingEnumerator::IGNORE); // Target decomposition - _target_decomposer.create(_target); + _target_decomposer = std::make_unique(_target); _target_decomposer->decompose(&target_vertices_filter); // Query vertices filter initialization @@ -153,7 +153,7 @@ void MoleculeExactSubstructureMatcher::_collectConnectedComponentsInfo() query_vertices_filter.init(_ee.getSubgraphMapping(), Filter::NEQ, EmbeddingEnumerator::IGNORE); // Query decomposition - _query_decomposer.create(_query); + _query_decomposer = std::make_unique(_query); _query_decomposer->decompose(&query_vertices_filter); } @@ -167,8 +167,8 @@ bool MoleculeExactSubstructureMatcher::_matchAtoms(Graph& subgraph, Graph& super if (flags & MoleculeExactMatcher::CONDITION_FRAGMENTS) { - const GraphDecomposer& target_decomposer = self->_target_decomposer.ref(); - const GraphDecomposer& query_decomposer = self->_query_decomposer.ref(); + const GraphDecomposer& target_decomposer = *self->_target_decomposer; + const GraphDecomposer& query_decomposer = *self->_query_decomposer; int super_component = target_decomposer.getComponent(super_idx); int sub_component = query_decomposer.getComponent(sub_idx); diff --git a/core/indigo-core/molecule/src/molecule_fingerprint.cpp b/core/indigo-core/molecule/src/molecule_fingerprint.cpp index 6a4a6465c7..eb4fe83a23 100644 --- a/core/indigo-core/molecule/src/molecule_fingerprint.cpp +++ b/core/indigo-core/molecule/src/molecule_fingerprint.cpp @@ -61,7 +61,7 @@ MoleculeFingerprintBuilder::MoleculeFingerprintBuilder(BaseMolecule& mol, const void MoleculeFingerprintBuilder::_initHashCalculations(BaseMolecule& mol, const Filter& vfilter) { - subgraph_hash.create(mol); + subgraph_hash = std::make_unique(mol); _atom_codes.clear_resize(mol.vertexEnd()); _atom_codes_empty.clear_resize(mol.vertexEnd()); @@ -600,18 +600,15 @@ void MoleculeFingerprintBuilder::_handleSubgraph(Graph& graph, const Array& void MoleculeFingerprintBuilder::_makeFingerprint(BaseMolecule& mol) { - Obj tau_super_structure; BaseMolecule* mol_for_enumeration = &mol; if (!query && _parameters.tau_qwords > 0 && !skip_tau) { - tau_super_structure.create(mol.asMolecule()); - - _tau_super_structure = tau_super_structure.get(); - mol_for_enumeration = tau_super_structure.get(); + _tau_super_structure = std::make_unique(mol.asMolecule()); + mol_for_enumeration = _tau_super_structure.get(); } else - _tau_super_structure = 0; + _tau_super_structure.reset(nullptr); if (!skip_ord || !skip_any_atoms || !skip_any_atoms_bonds || !skip_any_bonds || !skip_tau || !skip_sim) _makeFingerprint_calcOrdSim(*mol_for_enumeration); diff --git a/core/indigo-core/molecule/src/molecule_pi_systems_matcher.cpp b/core/indigo-core/molecule/src/molecule_pi_systems_matcher.cpp index d8084c13fb..e66dafb0c6 100644 --- a/core/indigo-core/molecule/src/molecule_pi_systems_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_pi_systems_matcher.cpp @@ -64,7 +64,7 @@ int MoleculePiSystemsMatcher::_initMarks(void) Filter filter(_atom_pi_system_idx.ptr(), Filter::NEQ, _NOT_IN_PI_SYSTEM); // Decompose 'pi_systems' into connected components - _decomposer.create(_target); + _decomposer = std::make_unique(_target); int n_comp = _decomposer->decompose(&filter); // Copy pi-system indices @@ -300,7 +300,7 @@ void MoleculePiSystemsMatcher::_extractPiSystem(int pi_system_index) } pi_system.localizations.clear(); - pi_system.localizer.create(pi_system.pi_system); + pi_system.localizer = std::make_unique(pi_system.pi_system); _findPiSystemLocalization(pi_system_index); } @@ -622,7 +622,7 @@ void MoleculePiSystemsMatcher::copyLocalization(Molecule& target) void MoleculePiSystemsMatcher::_Pi_System::clear() { initialized = false; - localizer.free(); + localizer.reset(nullptr); pi_system.clear(); inv_mapping.clear(); mapping.clear(); diff --git a/core/indigo-core/molecule/src/molecule_substructure_matcher.cpp b/core/indigo-core/molecule/src/molecule_substructure_matcher.cpp index cd6396ea78..ecef9b9d2c 100644 --- a/core/indigo-core/molecule/src/molecule_substructure_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_substructure_matcher.cpp @@ -252,10 +252,10 @@ void MoleculeSubstructureMatcher::setQuery(QueryMolecule& query) else _h_unfold = false; - if (_ee.get() != 0) - _ee.free(); + if (_ee.get() != nullptr) + _ee.reset(nullptr); - _ee.create(_target); + _ee = std::make_unique(_target); _ee->cb_match_vertex = _matchAtoms; _ee->cb_match_edge = _matchBonds; _ee->cb_vertex_remove = _removeAtom; @@ -270,7 +270,7 @@ void MoleculeSubstructureMatcher::setQuery(QueryMolecule& query) _ee->ignoreSubgraphVertex(i); } - _embeddings_storage.free(); + _embeddings_storage.reset(nullptr); } QueryMolecule& MoleculeSubstructureMatcher::getQuery() @@ -313,16 +313,16 @@ bool MoleculeSubstructureMatcher::find() _used_target_h.zerofill(); if (use_aromaticity_matcher && AromaticityMatcher::isNecessary(*_query)) - _am.create(*_query, _target, arom_options); + _am = std::make_unique(*_query, _target, arom_options); else - _am.free(); + _am.reset(nullptr); if (use_pi_systems_matcher && !_target.isQueryMolecule()) - _pi_systems_matcher.create(_target.asMolecule()); + _pi_systems_matcher = std::make_unique(_target.asMolecule()); else - _pi_systems_matcher.free(); + _pi_systems_matcher.reset(nullptr); - _3d_constraints_checker.recreate(_query->spatial_constraints); + _3d_constraints_checker = std::make_unique(_query->spatial_constraints); _createEmbeddingsStorage(); int result = _ee->process(); @@ -342,7 +342,7 @@ bool MoleculeSubstructureMatcher::find() void MoleculeSubstructureMatcher::_createEmbeddingsStorage() { - _embeddings_storage.create(); + _embeddings_storage = std::make_unique(); _embeddings_storage->unique_by_edges = find_unique_by_edges; _embeddings_storage->save_edges = save_for_iteration; _embeddings_storage->save_mapping = save_for_iteration; @@ -515,7 +515,7 @@ bool MoleculeSubstructureMatcher::matchQueryAtom(QueryMolecule::Atom* query, Bas } } -bool MoleculeSubstructureMatcher::matchQueryBond(QueryMolecule::Bond* query, BaseMolecule& target, int sub_idx, int super_idx, AromaticityMatcher* am, +bool MoleculeSubstructureMatcher::matchQueryBond(QueryMolecule::Bond* query, BaseMolecule& target, int sub_idx, int super_idx, const AromaticityMatcher* am, dword flags) { int i; @@ -1395,7 +1395,7 @@ bool MoleculeSubstructureMatcher::_isSingleBond(Graph& graph, int edge_idx) const GraphEmbeddingsStorage& MoleculeSubstructureMatcher::getEmbeddingsStorage() const { - return _embeddings_storage.ref(); + return *_embeddings_storage; } bool MoleculeSubstructureMatcher::needCoords(int match_3d, QueryMolecule& query) diff --git a/core/indigo-core/molecule/src/molecule_tautomer_match.cpp b/core/indigo-core/molecule/src/molecule_tautomer_match.cpp index a2cb22ac10..bca6322879 100644 --- a/core/indigo-core/molecule/src/molecule_tautomer_match.cpp +++ b/core/indigo-core/molecule/src/molecule_tautomer_match.cpp @@ -47,10 +47,10 @@ TautomerSearchContext::TautomerSearchContext(BaseMolecule& g1_, BaseMolecule& g2 else max_chains = 0; - dearomatizer.create(g2.asMolecule(), (int*)0, arom_options); + dearomatizer = std::make_unique(g2.asMolecule(), (int*)0, arom_options); dearomatizer->enumerateDearomatizations(dearomatizations); - dearomatizationMatcher.create(dearomatizations, g2.asMolecule(), (int*)0); + dearomatizationMatcher = std::make_unique(dearomatizations, g2.asMolecule(), (int*)0); } TautomerSearchContext::~TautomerSearchContext() diff --git a/core/indigo-core/molecule/src/molecule_tautomer_matcher.cpp b/core/indigo-core/molecule/src/molecule_tautomer_matcher.cpp index 732c7d9e61..646ac9beed 100644 --- a/core/indigo-core/molecule/src/molecule_tautomer_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_tautomer_matcher.cpp @@ -33,13 +33,13 @@ MoleculeTautomerMatcher::MoleculeTautomerMatcher(Molecule& target, bool substruc { if (substructure) { - _target.create(target); + _target = std::make_unique(target); _supermol = _target.get(); } else _supermol = ⌖ - _target_decomposer.create(*_supermol); + _target_decomposer = std::make_unique(*_supermol); _target_decomposer->decompose(); highlight = false; @@ -66,7 +66,7 @@ void MoleculeTautomerMatcher::setQuery(BaseMolecule& query) _query = std::make_unique(); _query->clone(query, 0, 0, 0); - _query_decomposer.create(query); + _query_decomposer = std::make_unique(query); _query_decomposer->decompose(); } diff --git a/core/indigo-core/molecule/src/molecule_tautomer_substructure_matcher.cpp b/core/indigo-core/molecule/src/molecule_tautomer_substructure_matcher.cpp index 0e40a7a25e..1f3a4dee17 100644 --- a/core/indigo-core/molecule/src/molecule_tautomer_substructure_matcher.cpp +++ b/core/indigo-core/molecule/src/molecule_tautomer_substructure_matcher.cpp @@ -62,9 +62,9 @@ void MoleculeTautomerSubstructureMatcher::setQuery(QueryMolecule& query) ignored.zerofill(); if (_ee.get() != 0) - _ee.free(); + _ee.reset(nullptr); - _ee.create(_tautomerEnumerator.layeredMolecules); + _ee = std::make_unique(_tautomerEnumerator.layeredMolecules); _ee->cb_match_vertex = _matchAtomsHyper; _ee->cb_match_edge = _matchBondsSubHyper; _ee->cb_edge_add = _edgeAddHyper; @@ -76,7 +76,7 @@ void MoleculeTautomerSubstructureMatcher::setQuery(QueryMolecule& query) _ee->setSubgraph(*_query); - _embeddings_storage.free(); + _embeddings_storage.reset(nullptr); _masks.clear(); } @@ -219,7 +219,7 @@ bool MoleculeTautomerSubstructureMatcher::findNext() void MoleculeTautomerSubstructureMatcher::_createEmbeddingsStorage() { - _embeddings_storage.create(); + _embeddings_storage = std::make_unique(); _embeddings_storage->unique_by_edges = find_unique_by_edges; _embeddings_storage->save_edges = save_for_iteration; _embeddings_storage->save_mapping = save_for_iteration; @@ -272,7 +272,7 @@ const int* MoleculeTautomerSubstructureMatcher::getTargetMapping() const GraphEmbeddingsStorage& MoleculeTautomerSubstructureMatcher::getEmbeddingsStorage() const { - return _embeddings_storage.ref(); + return *_embeddings_storage; } const Dbitset& MoleculeTautomerSubstructureMatcher::getMask(int ind) const diff --git a/core/indigo-core/reaction/base_reaction_substructure_matcher.h b/core/indigo-core/reaction/base_reaction_substructure_matcher.h index f72b63ff33..45f7fac7e1 100644 --- a/core/indigo-core/reaction/base_reaction_substructure_matcher.h +++ b/core/indigo-core/reaction/base_reaction_substructure_matcher.h @@ -19,7 +19,6 @@ #ifndef __base_reaction__substructure_matcher__ #define __base_reaction__substructure_matcher__ -#include "base_cpp/obj.h" #include "base_cpp/red_black.h" #include "base_cpp/tlscont.h" #include "graph/embedding_enumerator.h" @@ -138,7 +137,7 @@ namespace indigo BaseReactionSubstructureMatcher& _context; std::unique_ptr _am; - Obj _enumerator; + std::unique_ptr _enumerator; int _mode; int _selected_molecule_1; int _selected_molecule_2; diff --git a/core/indigo-core/reaction/crf_loader.h b/core/indigo-core/reaction/crf_loader.h index e705286f28..d3d65d9e49 100644 --- a/core/indigo-core/reaction/crf_loader.h +++ b/core/indigo-core/reaction/crf_loader.h @@ -19,10 +19,11 @@ #ifndef __crf_loader__ #define __crf_loader__ -#include "base_cpp/obj.h" #include "crf_saver.h" #include "lzw/lzw_decoder.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -57,7 +58,7 @@ namespace indigo Scanner& _scanner; - Obj _decoder; + std::unique_ptr _decoder; LzwDict* _dict; Array* _bond_rc_flags; diff --git a/core/indigo-core/reaction/crf_saver.h b/core/indigo-core/reaction/crf_saver.h index cefc9f69d8..fd2670b711 100644 --- a/core/indigo-core/reaction/crf_saver.h +++ b/core/indigo-core/reaction/crf_saver.h @@ -19,9 +19,10 @@ #ifndef __crf_saver__ #define __crf_saver__ -#include "base_cpp/obj.h" #include "lzw/lzw_encoder.h" +#include + #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4251) @@ -62,7 +63,7 @@ namespace indigo void _writeReactionMolecule(Reaction& reaction, int idx); Output& _output; - Obj _encoder; + std::unique_ptr _encoder; const int* _atom_stereo_flags; const int* _bond_rc_flags; diff --git a/core/indigo-core/reaction/reaction_enumerator_state.h b/core/indigo-core/reaction/reaction_enumerator_state.h index 3a8f92a3fd..e0e08ea189 100644 --- a/core/indigo-core/reaction/reaction_enumerator_state.h +++ b/core/indigo-core/reaction/reaction_enumerator_state.h @@ -19,7 +19,6 @@ #ifndef __reaction_enumerator_state__ #define __reaction_enumerator_state__ -#include "base_cpp/obj.h" #include "base_cpp/red_black.h" #include "base_cpp/reusable_obj_array.h" #include "graph/embedding_enumerator.h" @@ -30,6 +29,13 @@ #include "reaction/query_reaction.h" #include "reaction/reaction.h" +#include + +#ifdef _WIN32 +#pragma warning(push) +#pragma warning(disable : 4251) +#endif + namespace indigo { @@ -127,7 +133,7 @@ namespace indigo TL_CP_DECL(Array, _original_hydrogens); - AromaticityMatcher* _am; + std::shared_ptr _am; EmbeddingEnumerator* _ee; int _tube_idx; int _deep_level; @@ -258,4 +264,8 @@ namespace indigo } // namespace indigo +#ifdef _WIN32 +#pragma warning(pop) +#endif + #endif /* __reaction_enumerator_state__ */ diff --git a/core/indigo-core/reaction/reaction_substructure_matcher.h b/core/indigo-core/reaction/reaction_substructure_matcher.h index ab3350b0e7..5f55eed181 100644 --- a/core/indigo-core/reaction/reaction_substructure_matcher.h +++ b/core/indigo-core/reaction/reaction_substructure_matcher.h @@ -19,7 +19,6 @@ #ifndef __reaction_substructure_matcher__ #define __reaction_substructure_matcher__ -#include "base_cpp/obj.h" #include "graph/embedding_enumerator.h" #include "molecule/molecule_arom_match.h" #include "molecule/molecule_substructure_matcher.h" diff --git a/core/indigo-core/reaction/src/base_reaction_substructure_matcher.cpp b/core/indigo-core/reaction/src/base_reaction_substructure_matcher.cpp index 687214a4e1..5627458696 100644 --- a/core/indigo-core/reaction/src/base_reaction_substructure_matcher.cpp +++ b/core/indigo-core/reaction/src/base_reaction_substructure_matcher.cpp @@ -316,14 +316,14 @@ int BaseReactionSubstructureMatcher::_Matcher::_nextPair() if (_current_molecule_2 == _context._target.sideEnd()) return _NO_WAY; - _enumerator.free(); + _enumerator.reset(nullptr); BaseMolecule& mol_1 = _context._query->getBaseMolecule(_current_molecule_1); Molecule& mol_2 = _context._target.getMolecule(_current_molecule_2); if (!_initEnumerator(mol_1, mol_2)) { - _enumerator.free(); + _enumerator.reset(nullptr); continue; } break; @@ -452,7 +452,7 @@ int BaseReactionSubstructureMatcher::_Matcher::nextPair() bool BaseReactionSubstructureMatcher::_Matcher::_initEnumerator(BaseMolecule& mol_1, Molecule& mol_2) { // init embedding enumerator context - _enumerator.create(mol_2); + _enumerator = std::make_unique(mol_2); _enumerator->cb_match_edge = _matchBonds; _enumerator->cb_match_vertex = _matchAtoms; @@ -470,7 +470,7 @@ bool BaseReactionSubstructureMatcher::_Matcher::_initEnumerator(BaseMolecule& mo if (_context.prepare_ee != 0) { - if (!_context.prepare_ee(_enumerator.ref(), mol_1, mol_2, _context.context)) + if (!_context.prepare_ee(*_enumerator, mol_1, mol_2, _context.context)) return false; } diff --git a/core/indigo-core/reaction/src/crf_loader.cpp b/core/indigo-core/reaction/src/crf_loader.cpp index 075d795de5..91d0ef5c8f 100644 --- a/core/indigo-core/reaction/src/crf_loader.cpp +++ b/core/indigo-core/reaction/src/crf_loader.cpp @@ -35,7 +35,7 @@ void CrfLoader::_init() CrfLoader::CrfLoader(LzwDict& dict, Scanner& scanner) : _scanner(scanner) { _dict = &dict; - _decoder.create(dict, scanner); + _decoder = std::make_unique(dict, scanner); _init(); } @@ -94,13 +94,13 @@ void CrfLoader::_loadReactionMolecule(Reaction& reaction, int index, bool have_a void CrfLoader::_loadMolecule(Molecule& molecule) { - Obj loader; + std::unique_ptr loader; int i; - if (_decoder.get() != 0) - loader.create(_decoder.ref()); + if (_decoder.get() != nullptr) + loader = std::make_unique(*_decoder); else - loader.create(_scanner); + loader = std::make_unique(_scanner); QS_DEF(Array, atom_flags); QS_DEF(Array, bond_flags); @@ -155,7 +155,7 @@ void CrfLoader::_loadMolecule(Molecule& molecule) { int value; - if (_decoder.get() != 0) + if (_decoder.get() != nullptr) value = _decoder->get(); else value = _scanner.readByte(); diff --git a/core/indigo-core/reaction/src/crf_saver.cpp b/core/indigo-core/reaction/src/crf_saver.cpp index a00e05b76d..c317e034d6 100644 --- a/core/indigo-core/reaction/src/crf_saver.cpp +++ b/core/indigo-core/reaction/src/crf_saver.cpp @@ -41,7 +41,7 @@ CrfSaver::CrfSaver(LzwDict& dict, Output& output) : _output(output) if (!dict.isInitialized()) dict.init(CMF_ALPHABET_SIZE, CMF_BIT_CODE_SIZE); - _encoder.create(dict, output); + _encoder = std::make_unique(dict, output); _init(); } @@ -86,18 +86,18 @@ void CrfSaver::_writeReactionMolecule(Reaction& reaction, int i) void CrfSaver::_writeMolecule(Molecule& molecule) { - Obj saver; + std::unique_ptr saver; int i; if (_encoder.get() != 0) - saver.create(_encoder.ref()); + saver = std::make_unique(*_encoder); else - saver.create(_output); + saver = std::make_unique(_output); QS_DEF(Array, atom_flags); QS_DEF(Array, bond_flags); - if (_atom_stereo_flags != 0) + if (_atom_stereo_flags != nullptr) { atom_flags.clear_resize(molecule.vertexEnd()); atom_flags.zerofill(); @@ -110,7 +110,7 @@ void CrfSaver::_writeMolecule(Molecule& molecule) saver->atom_flags = atom_flags.ptr(); } - if (_bond_rc_flags != 0) + if (_bond_rc_flags != nullptr) { bond_flags.clear_resize(molecule.edgeEnd()); bond_flags.zerofill(); @@ -133,17 +133,17 @@ void CrfSaver::_writeMolecule(Molecule& molecule) saver->saveMolecule(molecule); - if (_aam != 0) + if (_aam != nullptr) _writeAam(_aam, saver->getAtomSequence()); - if (xyz_output != 0) + if (xyz_output != nullptr) { - if (xyz_output == &_output && _encoder.get() != 0) + if (xyz_output == &_output && _encoder.get() != nullptr) _encoder->finish(); saver->saveXyz(*xyz_output); - if (xyz_output == &_output && _encoder.get() != 0) + if (xyz_output == &_output && _encoder.get() != nullptr) _encoder->start(); } } diff --git a/core/indigo-core/reaction/src/reaction_enumerator_state.cpp b/core/indigo-core/reaction/src/reaction_enumerator_state.cpp index 78feea0dfc..3bff2c8200 100644 --- a/core/indigo-core/reaction/src/reaction_enumerator_state.cpp +++ b/core/indigo-core/reaction/src/reaction_enumerator_state.cpp @@ -216,6 +216,7 @@ ReactionEnumeratorState::ReactionEnumeratorState(ReactionEnumeratorState& cur_rp Array& new_array = _att_points.push(); new_array.copy(cur_rpe_state._att_points[i]); } + // 2DO: check memory leaks _am = cur_rpe_state._am; _ee = cur_rpe_state._ee; @@ -627,10 +628,7 @@ bool ReactionEnumeratorState::_startEmbeddingEnumerator(Molecule& monomer) ee_monomer.buildCisTrans(cis_trans_excluded.ptr()); } - QS_DEF(Obj, am); - am.free(); - am.create(ee_reactant, ee_monomer, _context.arom_options); - _am = am.get(); + _am = std::make_shared(ee_reactant, ee_monomer, _context.arom_options); ee_monomer.unfoldHydrogens(NULL, _calcMaxHCnt(ee_reactant), true); @@ -760,7 +758,7 @@ bool ReactionEnumeratorState::_matchEdgeCallback(Graph& subgraph, Graph& supergr if (rpe_state->_bonds_mapping_super[other_idx] >= 0) return false; - bool res = MoleculeSubstructureMatcher::matchQueryBond(&qb_sub, supermolecule, self_idx, other_idx, rpe_state->_am, 0xFFFFFFFFUL); + bool res = MoleculeSubstructureMatcher::matchQueryBond(&qb_sub, supermolecule, self_idx, other_idx, rpe_state->_am.get(), 0xFFFFFFFFUL); return res; } From 074318a79c7090ddeb4a88e61d8fc5676f810077 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:04:51 +0300 Subject: [PATCH 2/5] fix typo --- bingo/bingo-core/src/core/mango_substructure.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/bingo/bingo-core/src/core/mango_substructure.cpp b/bingo/bingo-core/src/core/mango_substructure.cpp index 73a9aebffb..94d1a9d33f 100644 --- a/bingo/bingo-core/src/core/mango_substructure.cpp +++ b/bingo/bingo-core/src/core/mango_substructure.cpp @@ -317,7 +317,6 @@ bool MangoSubstructure::matchBinary(Scanner& scanner, Scanner* xyz_scanner) profTimerStart(tcmf, "match.cmf"); - cmf_loader.free(); cmf_loader = std::make_unique(_context.cmf_dict, scanner); if (!_query_has_stereocare_bonds) From 434cf487aaacf8efb9f243fb63fd6c34fae6d137 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 30 Apr 2025 18:45:23 +0300 Subject: [PATCH 3/5] Fix typos --- bingo/oracle/src/oracle/bingo_fingerprints.cpp | 14 +++++++------- bingo/oracle/src/oracle/mango_shadow_table.cpp | 4 ++-- bingo/oracle/src/oracle/rowid_saver.h | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bingo/oracle/src/oracle/bingo_fingerprints.cpp b/bingo/oracle/src/oracle/bingo_fingerprints.cpp index 4f0108d6cb..9500792fba 100644 --- a/bingo/oracle/src/oracle/bingo_fingerprints.cpp +++ b/bingo/oracle/src/oracle/bingo_fingerprints.cpp @@ -275,11 +275,11 @@ bool BingoFingerprints::screenPart_Init(OracleEnv& env, Screening& screening) screening.block = &_all_blocks[screening.part]; screening.statement = std::make_unique(env); - screening.bits_lob = std::make_unique(env); + screening.bits_lob = std::make_unique(env); screening.statement->append("SELECT bits FROM %s WHERE part = :part", _table_name.ptr()); screening.statement->prepare(); screening.statement->bindIntByName(":part", &screening.part); - screening.statement->defineBlobByPos(1, screening.bits_lob.ref()); + screening.statement->defineBlobByPos(1, *screening.bits_lob); screening.statement->execute(); } else @@ -409,8 +409,8 @@ void BingoFingerprints::screenPart_End(OracleEnv& env, Screening& screening) { int i; - screening.bits_lob.free(); - screening.statement.free(); + screening.bits_lob.reset(); + screening.statement.reset(); profTimerStart(tsort, "fingerprints.end"); for (i = 0; i < screening.passed_pre.size(); i++) @@ -466,7 +466,7 @@ bool BingoFingerprints::countOnes_Init(OracleEnv& env, Screening& screening) screening.statement->append("SELECT bits FROM %s WHERE part = :part", _table_name.ptr()); screening.statement->prepare(); screening.statement->bindIntByName(":part", &screening.part); - screening.statement->defineBlobByPos(1, screening.bits_lob.ref()); + screening.statement->defineBlobByPos(1, *screening.bits_lob); screening.statement->execute(); screening.block = &_all_blocks[screening.part]; @@ -513,8 +513,8 @@ bool BingoFingerprints::countOnes_Next(OracleEnv& env, Screening& screening) void BingoFingerprints::countOnes_End(OracleEnv& env, Screening& screening) { - screening.bits_lob.free(); - screening.statement.free(); + screening.bits_lob.reset(); + screening.statement.reset(); screening.part++; } diff --git a/bingo/oracle/src/oracle/mango_shadow_table.cpp b/bingo/oracle/src/oracle/mango_shadow_table.cpp index 3b79f9aa59..d4f4ba1c42 100644 --- a/bingo/oracle/src/oracle/mango_shadow_table.cpp +++ b/bingo/oracle/src/oracle/mango_shadow_table.cpp @@ -230,7 +230,7 @@ void MangoShadowTable::_flushMain(OracleEnv& env) } profTimerStop(tmain); - _main_table_statement.free(); + _main_table_statement.reset(); _pending_rid.clear(); _pending_blockno.clear(); _pending_offset.clear(); @@ -269,7 +269,7 @@ void MangoShadowTable::_flushComponents(OracleEnv& env) _pending_comp_hash.clear(); profTimerStop(tcomp); } - _components_table_statement.free(); + _components_table_statement.reset(); _components_table_statement_count = 0; } } diff --git a/bingo/oracle/src/oracle/rowid_saver.h b/bingo/oracle/src/oracle/rowid_saver.h index 8bfe9b0196..6094c8e418 100644 --- a/bingo/oracle/src/oracle/rowid_saver.h +++ b/bingo/oracle/src/oracle/rowid_saver.h @@ -23,7 +23,6 @@ #include "lzw/lzw_dictionary.h" #include "lzw/lzw_encoder.h" -#include "base_cpp/obj.h" #include "oracle/rowid_symbol_codes.h" #include From b0eb294003f8a07906d07abb8bfdee3f932e785a Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 30 Apr 2025 20:04:43 +0300 Subject: [PATCH 4/5] Fix typos --- bingo/bingo-core-c/src/bingo_core_c.cpp | 38 +++++++++---------- .../src/bingo_core_c_parallel.cpp | 2 +- bingo/bingo-core-c/src/mango_core_c.cpp | 6 +-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/bingo/bingo-core-c/src/bingo_core_c.cpp b/bingo/bingo-core-c/src/bingo_core_c.cpp index 3f65e04089..440e349ff6 100644 --- a/bingo/bingo-core-c/src/bingo_core_c.cpp +++ b/bingo/bingo-core-c/src/bingo_core_c.cpp @@ -388,8 +388,8 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str) QS_DEF(Array, column); BufferScanner scanner(fields_str); - self.import_properties.free(); - self.import_columns.free(); + self.import_properties.reset(); + self.import_columns.reset(); self.import_properties = std::make_unique(); self.import_columns = std::make_unique(); @@ -402,8 +402,8 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str) scanner.readWord(column, " ,"); scanner.skipSpace(); - self.import_properties.ref().add(prop.ptr()); - self.import_columns.ref().add(column.ptr()); + self.import_properties->add(prop.ptr()); + self.import_columns->add(column.ptr()); if (scanner.isEOF()) break; @@ -412,7 +412,7 @@ int BingoCore::bingoImportParseFieldList(const char* fields_str) throw BingoError("importParseFieldList(): comma expected"); scanner.skipSpace(); } - return self.import_properties.ref().size(); + return self.import_properties->size(); } CEXPORT int bingoImportParseFieldList(const char* fields_str) @@ -428,7 +428,7 @@ const char* BingoCore::bingoImportGetColumnName(int idx) { if (self.import_columns.get() == 0) throw BingoError("bingo import list has not been parsed yet"); - return self.import_columns.ref().at(idx); + return self.import_columns->at(idx); } CEXPORT const char* bingoImportGetColumnName(int idx) @@ -446,7 +446,7 @@ CEXPORT const char* bingoImportGetPropertyName(int idx) { if (self.import_properties.get() == 0) throw BingoError("bingo import list has not been parsed yet"); - return self.import_properties.ref().at(idx); + return self.import_properties->at(idx); } BINGO_END("", ""); } @@ -455,7 +455,7 @@ const char* BingoCore::bingoImportGetPropertyValue(int idx) { if (self.import_properties.get() == 0) throw BingoError("bingo import list has not been parsed yet"); - const char* property_name = self.import_properties.ref().at(idx); + const char* property_name = self.import_properties->at(idx); if (self.sdf_loader.get()) { return self.sdf_loader->properties.at(property_name); @@ -487,7 +487,7 @@ void BingoCore::bingoSDFImportOpen(const char* file_name) { self.bingoSDFImportClose(); self.file_scanner = std::make_unique(file_name); - self.sdf_loader = std::make_unique(self.file_scanner.ref()); + self.sdf_loader = std::make_unique(*self.file_scanner); } CEXPORT int bingoSDFImportOpen(const char* file_name) @@ -501,8 +501,8 @@ CEXPORT int bingoSDFImportOpen(const char* file_name) void BingoCore::bingoSDFImportClose() { - self.sdf_loader.free(); - self.file_scanner.free(); + self.sdf_loader.reset(); + self.file_scanner.reset(); } CEXPORT int bingoSDFImportClose() @@ -558,7 +558,7 @@ void BingoCore::bingoRDFImportOpen(const char* file_name) { self.bingoRDFImportClose(); self.file_scanner = std::make_unique(file_name); - self.rdf_loader = std::make_unique(self.file_scanner.ref()); + self.rdf_loader = std::make_unique(*self.file_scanner); } CEXPORT int bingoRDFImportOpen(const char* file_name) @@ -572,8 +572,8 @@ CEXPORT int bingoRDFImportOpen(const char* file_name) void BingoCore::bingoRDFImportClose() { - self.rdf_loader.free(); - self.file_scanner.free(); + self.rdf_loader.reset(); + self.file_scanner.reset(); } CEXPORT int bingoRDFImportClose() @@ -773,14 +773,14 @@ static void _bingoIndexEnd(BingoCore& self) } if (self.single_mango_index.get()) - self.single_mango_index.free(); + self.single_mango_index.reset(); if (self.single_ringo_index.get()) - self.single_ringo_index.free(); + self.single_ringo_index.reset(); self.mango_index = 0; self.ringo_index = 0; self.index_record_data_id = -1; - self.index_record_data.free(); + self.index_record_data.reset(); } int BingoCore::bingoIndexEnd() @@ -839,7 +839,7 @@ void BingoCore::bingoSMILESImportOpen(const char* file_name) self.file_scanner->seek(pos, SEEK_SET); if (magic[0] == 0x1f && magic[1] == 0x8b) { - self.gz_scanner = std::make_unique(self.file_scanner.ref()); + self.gz_scanner = std::make_unique(*self.file_scanner); self.smiles_scanner = self.gz_scanner.get(); } else @@ -858,7 +858,7 @@ CEXPORT int bingoSMILESImportOpen(const char* file_name) void BingoCore::bingoSMILESImportClose() { self.gz_scanner.reset(nullptr); - self.file_scanner.free(); + self.file_scanner.reset(); self.smiles_scanner = 0; } diff --git a/bingo/bingo-core-c/src/bingo_core_c_parallel.cpp b/bingo/bingo-core-c/src/bingo_core_c_parallel.cpp index febd5cee26..7d621a0ba4 100644 --- a/bingo/bingo-core-c/src/bingo_core_c_parallel.cpp +++ b/bingo/bingo-core-c/src/bingo_core_c_parallel.cpp @@ -112,7 +112,7 @@ bool IndexingDispatcher::_setupCommand(OsCommand& cmd) _finished = true; break; } - command.records.add(_core.index_record_data.ref()); + command.records.add(*_core.index_record_data); command.ids.push(_core.index_record_data_id); } return command.ids.size() != 0; diff --git a/bingo/bingo-core-c/src/mango_core_c.cpp b/bingo/bingo-core-c/src/mango_core_c.cpp index 13daa9125d..f6bcd881ca 100644 --- a/bingo/bingo-core-c/src/mango_core_c.cpp +++ b/bingo/bingo-core-c/src/mango_core_c.cpp @@ -44,7 +44,7 @@ using namespace indigo::bingo_core; int BingoCore::mangoIndexProcessSingleRecord() { - BufferScanner scanner(self.index_record_data.ref()); + BufferScanner scanner(*self.index_record_data); NullOutput output; @@ -479,7 +479,7 @@ int BingoCore::mangoMatchTargetBinary(const char* target_bin, int target_bin_len if (self.mango_search_type == BingoCore::_SUBSTRUCTRE) { MangoSubstructure& substructure = self.mango_context->substructure; - return substructure.matchBinary(scanner, xyz_scanner) ? 1 : 0; + return substructure.matchBinary(scanner, xyz_scanner.get()) ? 1 : 0; } else if (self.mango_search_type == BingoCore::_TAUTOMER) { @@ -489,7 +489,7 @@ int BingoCore::mangoMatchTargetBinary(const char* target_bin, int target_bin_len else if (self.mango_search_type == BingoCore::_EXACT) { MangoExact& exact = self.mango_context->exact; - return exact.matchBinary(scanner, xyz_scanner) ? 1 : 0; + return exact.matchBinary(scanner, xyz_scanner.get()) ? 1 : 0; } else if (self.mango_search_type == BingoCore::_SIMILARITY) { From b484c1696a1595e81f9bdd3c12ca41b0f328d4f7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Wed, 30 Apr 2025 21:40:22 +0300 Subject: [PATCH 5/5] fix typo --- bingo/bingo-core-c/src/ringo_core_c.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bingo/bingo-core-c/src/ringo_core_c.cpp b/bingo/bingo-core-c/src/ringo_core_c.cpp index ef0e4eb810..af786ce74f 100644 --- a/bingo/bingo-core-c/src/ringo_core_c.cpp +++ b/bingo/bingo-core-c/src/ringo_core_c.cpp @@ -37,7 +37,7 @@ using namespace indigo::bingo_core; int BingoCore::ringoIndexProcessSingleRecord() { - BufferScanner scanner(self.index_record_data.ref()); + BufferScanner scanner(*self.index_record_data); NullOutput output;