/src/openbabel/src/ops/addpolarh.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************** |
2 | | AddPolarH.cpp - The option --AddPolarHAdds adds hydrogen to polar atoms only. |
3 | | |
4 | | Copyright(C) 2007 by Chris Morley |
5 | | |
6 | | This file is part of the Open Babel project. |
7 | | For more information, see <http://openbabel.org/> |
8 | | |
9 | | This program is free software; you can redistribute it and/or modify |
10 | | it under the terms of the GNU General Public License as published by |
11 | | the Free Software Foundation version 2 of the License. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | ***********************************************************************/ |
18 | | #include <openbabel/babelconfig.h> |
19 | | #include <iostream> |
20 | | #include<openbabel/op.h> |
21 | | #include<openbabel/mol.h> |
22 | | |
23 | | namespace OpenBabel |
24 | | { |
25 | | |
26 | | class OpAddPolarH : public OBOp |
27 | | { |
28 | | public: |
29 | 2 | OpAddPolarH(const char* ID) : OBOp(ID, false){}; |
30 | 0 | const char* Description() override { return "Adds hydrogen to polar atoms only"; } |
31 | | |
32 | 0 | bool WorksWith(OBBase* pOb) const override { return dynamic_cast<OBMol*>(pOb) != nullptr; } |
33 | | bool Do(OBBase* pOb, const char* OptionText=nullptr, OpMap* pOptions=nullptr, |
34 | | OBConversion* pConv=nullptr) override; |
35 | | }; |
36 | | |
37 | | ///////////////////////////////////////////////////////////////// |
38 | | OpAddPolarH theOpAddPolarH("AddPolarH"); //Global instance |
39 | | |
40 | | ///////////////////////////////////////////////////////////////// |
41 | | bool OpAddPolarH::Do(OBBase* pOb, const char* OptionText, OpMap* pOptions, OBConversion* pConv) |
42 | 0 | { |
43 | 0 | OBMol* pmol = dynamic_cast<OBMol*>(pOb); |
44 | 0 | if(!pmol) |
45 | 0 | return false; |
46 | | |
47 | 0 | pmol->AddPolarHydrogens(); |
48 | |
|
49 | 0 | return true; |
50 | 0 | } |
51 | | }//namespace |