From 010128ec4c4e58272a91a95adbcf7507d44edeb6 Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 21 Sep 2010 17:05:42 +0000 Subject: [PATCH] moved chemdict parser from conop to io to avoid circular dependency git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2724 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/conop/src/CMakeLists.txt | 2 -- modules/conop/src/chemdict_tool.cc | 4 ++-- modules/io/src/mol/CMakeLists.txt | 2 ++ .../src => io/src/mol}/chemdict_parser.cc | 12 ++++++---- .../src => io/src/mol}/chemdict_parser.hh | 24 +++++++++---------- 5 files changed, 23 insertions(+), 21 deletions(-) rename modules/{conop/src => io/src/mol}/chemdict_parser.cc (95%) rename modules/{conop/src => io/src/mol}/chemdict_parser.hh (76%) diff --git a/modules/conop/src/CMakeLists.txt b/modules/conop/src/CMakeLists.txt index 21749612f..4d0840ea3 100644 --- a/modules/conop/src/CMakeLists.txt +++ b/modules/conop/src/CMakeLists.txt @@ -8,11 +8,9 @@ compound_lib.hh module_config.hh rule_based_builder.hh ring_finder.hh -chemdict_parser.hh ) set(OST_CONOP_SOURCES -chemdict_parser.cc builder.cc conop.cc heuristic_builder.cc diff --git a/modules/conop/src/chemdict_tool.cc b/modules/conop/src/chemdict_tool.cc index 929c49745..65fca9310 100644 --- a/modules/conop/src/chemdict_tool.cc +++ b/modules/conop/src/chemdict_tool.cc @@ -29,7 +29,7 @@ #include <boost/iostreams/filter/gzip.hpp> -#include <ost/conop/chemdict_parser.hh> +#include <ost/io/mol/chemdict_parser.hh> using namespace ost; @@ -70,7 +70,7 @@ int main(int argc, char const *argv[]) filtered_istream.push(boost::iostreams::gzip_decompressor()); } filtered_istream.push(istream); - conop::ChemdictParser cdp(filtered_istream, dialect); + io::ChemdictParser cdp(filtered_istream, dialect); conop::CompoundLibPtr compound_lib; if (!strcmp(argv[1], "create")) { compound_lib=conop::CompoundLib::Create(argv[3]); diff --git a/modules/io/src/mol/CMakeLists.txt b/modules/io/src/mol/CMakeLists.txt index 860b4df0d..849885845 100644 --- a/modules/io/src/mol/CMakeLists.txt +++ b/modules/io/src/mol/CMakeLists.txt @@ -12,12 +12,14 @@ save_entity.cc load_entity.cc surface_io_msms_handler.cc load_surface.cc +chemdict_parser.cc dcd_io.cc star_parser.cc PARENT_SCOPE ) set(OST_IO_MOL_HEADERS +chemdict_parser.hh star_parser.hh dcd_io.hh entity_io_crd_handler.hh diff --git a/modules/conop/src/chemdict_parser.cc b/modules/io/src/mol/chemdict_parser.cc similarity index 95% rename from modules/conop/src/chemdict_parser.cc rename to modules/io/src/mol/chemdict_parser.cc index 511add0a6..af8b08404 100644 --- a/modules/conop/src/chemdict_parser.cc +++ b/modules/io/src/mol/chemdict_parser.cc @@ -1,7 +1,9 @@ -#include <ost/conop/chemdict_parser.hh> +#include <ost/io/mol/chemdict_parser.hh> -namespace ost { namespace conop { +namespace ost { namespace io { +using namespace ost::conop; + bool ChemdictParser::OnBeginData(const StringRef& data_name) { compound_.reset(new Compound(data_name.str())); @@ -15,7 +17,7 @@ bool ChemdictParser::OnBeginData(const StringRef& data_name) return true; } -bool ChemdictParser::OnBeginLoop(const io::StarLoopDesc& header) +bool ChemdictParser::OnBeginLoop(const StarLoopDesc& header) { if (header.GetCategory()=="chem_comp_atom") { loop_type_=ATOM_SPEC; @@ -37,7 +39,7 @@ bool ChemdictParser::OnBeginLoop(const io::StarLoopDesc& header) return false; } -void ChemdictParser::OnDataRow(const io::StarLoopDesc& header, +void ChemdictParser::OnDataRow(const StarLoopDesc& header, const std::vector<StringRef>& columns) { if (loop_type_==ATOM_SPEC) { @@ -65,7 +67,7 @@ void ChemdictParser::OnDataRow(const io::StarLoopDesc& header, } } -void ChemdictParser::OnDataItem(const io::StarDataItem& item) +void ChemdictParser::OnDataItem(const StarDataItem& item) { if (item.GetCategory()==StringRef("chem_comp", 9)) { if (item.GetName()==StringRef("type", 4)) { diff --git a/modules/conop/src/chemdict_parser.hh b/modules/io/src/mol/chemdict_parser.hh similarity index 76% rename from modules/conop/src/chemdict_parser.hh rename to modules/io/src/mol/chemdict_parser.hh index f08b84b2c..a21b437b8 100644 --- a/modules/conop/src/chemdict_parser.hh +++ b/modules/io/src/mol/chemdict_parser.hh @@ -28,7 +28,7 @@ #include <ost/io/mol/star_parser.hh> #include <ost/conop/compound_lib.hh> -namespace ost { namespace conop { +namespace ost { namespace io { typedef enum { ATOM_SPEC, @@ -36,10 +36,10 @@ typedef enum { DONT_KNOW } LoopType; -class DLLEXPORT_OST_CONOP ChemdictParser : public io::StarParser { +class DLLEXPORT_OST_CONOP ChemdictParser : public StarParser { public: - ChemdictParser(std::istream& stream, Compound::Dialect dialect): - io::StarParser(stream), compound_(new Compound("UNK")), + ChemdictParser(std::istream& stream, conop::Compound::Dialect dialect): + StarParser(stream), compound_(new conop::Compound("UNK")), last_(0), loop_type_(DONT_KNOW), dialect_(dialect) { this->InitTypeMap(); @@ -47,23 +47,23 @@ public: virtual bool OnBeginData(const StringRef& data_name); - virtual bool OnBeginLoop(const io::StarLoopDesc& header); + virtual bool OnBeginLoop(const StarLoopDesc& header); - virtual void OnDataRow(const io::StarLoopDesc& header, + virtual void OnDataRow(const StarLoopDesc& header, const std::vector<StringRef>& columns); - virtual void OnDataItem(const io::StarDataItem& item); + virtual void OnDataItem(const StarDataItem& item); virtual void OnEndData(); - void SetCompoundLib(const CompoundLibPtr& lib) + void SetCompoundLib(const conop::CompoundLibPtr& lib) { lib_=lib; } private: void InitTypeMap(); - CompoundLibPtr lib_; - CompoundPtr compound_; + conop::CompoundLibPtr lib_; + conop::CompoundPtr compound_; typedef enum { ATOM_NAME=0, ALT_ATOM_NAME=1, @@ -82,8 +82,8 @@ private: static std::map<String, mol::ChemClass> tm_; std::map<String, int> atom_map_; LoopType loop_type_; - AtomSpec atom_; - Compound::Dialect dialect_; + conop::AtomSpec atom_; + conop::Compound::Dialect dialect_; }; -- GitLab