File: ops.cpp

package info (click to toggle)
openbabel 2.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 36,644 kB
  • ctags: 33,717
  • sloc: cpp: 242,528; ansic: 87,037; sh: 10,280; perl: 5,518; python: 5,156; pascal: 793; makefile: 747; cs: 392; xml: 97; ruby: 54; java: 23
file content (78 lines) | stat: -rw-r--r-- 2,451 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**********************************************************************
ops.cpp - Some simple plugins for OBMol to implement some general options

Copyright (C) 2007 by Chris Morley
 
This file is part of the Open Babel project.
For more information, see <http://openbabel.sourceforge.net/>
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
***********************************************************************/

#include <openbabel/babelconfig.h>
#include <openbabel/op.h>
#include <openbabel/mol.h>

#ifndef OBERROR
 #define OBERROR
#endif


namespace OpenBabel
{
  /* This works ok but duplicates the -c option*/
  class OpCenter : public OBOp
  {
  public:
    OpCenter(const char* ID) : OBOp(ID, false){};
    virtual const char* Description(){ return "Centers coordinates around (0,0,0)"; }
    virtual bool WorksWith(OBBase* pOb)const{ return dynamic_cast<OBMol*>(pOb)!=NULL; }

    virtual bool Do(OBBase* pOb, OpMap*, const char*)
    {
      OBMol* pmol = dynamic_cast<OBMol*>(pOb);
      if(pmol)
        pmol->Center();
      return true;
    }
  };

  //////////////////////////////////////////////////////
  OpCenter theOpCenter("center"); //Global instance

  //*************************************************************

  /* This class is another example -- use the FROG code to generate 3D coords.
  class OpFrog : public OBOp
  {
  public:
    OpFrog(const char* ID) : OBOp(ID, false){};
    virtual const char* Description()
    { return "Adds 3D coordinates using the FROG code"; }
    virtual bool WorksWith(OBBase* pOb)const
    { return dynamic_cast<OBMol*>(pOb)!=NULL; }

    virtual bool Do(OBBase* pOb, OpMap*, const char*);
  };

  ///////////////////////////////////////////////////////
  //Global instance with option name used 
  // e.g. babel infile.xxx -O outfile.yyy --3Dfrog
  OpFrog theOpFrog("3Dfrog"); 

  //////////////////////////////////////////////////////
  bool OpFrog::Do(OBBase* pOb, OpMap*, const char*)
  { return true; }
  */

}//namespace

//! \file ops.cpp
//! \brief Base plugin class for operations on molecules