Open Babel: atomclass.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

# atomclass.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002 Copyright (C) 2007 by Chris Morley
    00003
    00004 This program is free software; you can redistribute it and/or modify
    00005 it under the terms of the GNU General Public License as published by
    00006 the Free Software Foundation version 2 of the License.
    00007
    00008 This program is distributed in the hope that it will be useful,
    00009 but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00011 GNU General Public License for more details.
    00012 ***********************************************************************/
    00013
    00014 #ifndef OB_ATOMCLASS_H
    00015 #define OB_ATOMCLASS_H
    00016
    00017 #include <openbabel/babelconfig.h>
    00018
    00019 #include <vector>
    00020 #include <sstream>
    00021 #include <openbabel/base.h>
    00022
    00023 namespace OpenBabel
    00024 {
    00025 // This macro is used in DLL builds. If it has not
    00026 // been set in babelconfig.h, define it as nothing.
    00027 #ifndef OBAPI
    00028   #define OBAPI
    00029 #endif
    00030
    00040 class OBAPI OBAtomClassData : public OBGenericData
    00041 {
    00042 protected:
    00043   std::map<int,int> _map; //index is atom index; value is class
    00044 public:
    00045   OBAtomClassData(): OBGenericData("Atom Class", 0x7882){ }
    00046   virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBAtomClassData(*this);}
    00047
    00049   void Clear(){ _map.clear(); }
    00050
    00052   void Add(int indx, int cl) { _map[indx] = cl;}
    00053
    00055   bool HasClass(int indx)const { return _map.find(indx)!=_map.end(); }
    00057   int GetClass(int indx)const
    00058   {
    00059     std::map<int,int>::const_iterator pos = _map.find(indx);
    00060     if(pos!=_map.end())
    00061       return pos->second;
    00062     return -9999;
    00063   }
    00064
    00067   std::string GetClassString(int indx)
    00068   {
    00069     std::stringstream ss;
    00070     std::map<int,int>::const_iterator pos = _map.find(indx);
    00071     if(pos!=_map.end())
    00072       ss << ':' << pos->second;
    00073     return ss.str();
    00074   }
    00075   int size(){ return _map.size(); }
    00076
    00077 };
    00078 } //namespace
    00079
    00080 #endif // OB_ATOMCLASS_H
    00081

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This file is part of the documentation for Open Babel, version 2.3.

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by:
Generated on Mon Oct 25 2010 11:55:07 by 1.7.2.