Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConstraintFactory.cc
Go to the documentation of this file.
1  // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/scoring/constraints/ConstraintFactory.cc
11 /// @brief Factory for creating various types of constraints.
12 /// @author Greg Taylor <gktaylor@u.washington.edu>
13 
14 // Unit headers
16 
17 // Package headers
20 
21 #include <utility/vector1.hh>
22 
23 
24 //#include <core/scoring/constraints/AtomPairConstraint.hh>
25 //#include <core/scoring/constraints/DunbrackConstraint.hh>
26 //#include <core/scoring/constraints/AmbiguousConstraint.hh>
27 //#include <core/scoring/constraints/KofNConstraint.hh>
28 //#include <core/scoring/constraints/AngleConstraint.hh>
29 //#include <core/scoring/constraints/BigBinConstraint.hh>
30 //#include <core/scoring/constraints/DihedralConstraint.hh>
31 //#include <core/scoring/constraints/BindingSiteConstraint.hh>
32 //#include <core/scoring/constraints/BindingSiteConstraintResidues.hh>
33 //#include <core/scoring/constraints/CoordinateConstraint.hh>
34 //#include <core/scoring/constraints/MultiConstraint.hh>
35 //#include <core/scoring/constraints/LocalCoordinateConstraint.hh>
36 //#include <core/scoring/constraints/AmbiguousNMRDistanceConstraint.hh>
37 //#include <core/scoring/constraints/AmbiguousNMRConstraint.hh>
38 //#include <core/scoring/constraints/ResidueTypeConstraint.hh>
39 
40 namespace core {
41 namespace scoring {
42 namespace constraints {
43 
44 ConstraintFactory * ConstraintFactory::instance_( 0 );
45 
46 /// @details Private constructor insures correctness of singleton.
48 
51 {
52  if ( instance_ == 0 ) {
54  }
55  return instance_;
56 }
57 
58 /*
59 void
60 ConstraintFactory::add_type( ConstraintOP new_func ) {
61  std::string type_name = new_func->type();
62  if ( type_name == "UNKNOWN_TYPE" ) {
63  utility_exit_with_message(
64  "failed to register Constraint... define method type() for your constraint!"
65  );
66  }
67  cst_types_[ type_name ] = new_func;
68 }
69 
70 void
71 ConstraintFactory::add_type( std::string const & type_name, ConstraintOP new_func ) {
72  cst_types_[ type_name ] = new_func;
73 }*/
74 
75 void
77 {
78  cst_types_[ creator->keyname() ] = creator;
79 }
80 
83 {
84  ConstraintCreatorMap::const_iterator iter = cst_types_.find( type_name );
85  if ( iter != cst_types_.end() ) {
86  return iter->second->create_constraint();
87  } else {
88 
89  using std::string;
90  using utility::vector1;
91  string msg("ConstraintFactory::newConstraint: ");
92  msg += type_name + " does not name a known ConstraintType --> " +
93  "check spelling or register new Constraint type in ConstraintFactory!";
94 
95  msg += "known types are:\n";
97  for ( vector1< string >::const_iterator it = types.begin(), end = types.end(); it != end; ++it ) {
98  msg += *it + "\n";
99  }
100 
101  utility_exit_with_message( msg );
102  }
103  return 0;
104 }
105 
108  using std::string;
109  using utility::vector1;
110 
111  vector1< string > cst_names;
112  for ( ConstraintCreatorMap::const_iterator
113  it = cst_types_.begin(), end = cst_types_.end(); it != end; ++it ) {
114  cst_names.push_back( it->first );
115  }
116 
117  return cst_names;
118 }
119 
121 {
122  cst_types_[ creator->keyname() ] = creator;
123 }
124 
127 {
128  ConstraintCreatorMap::const_iterator iter = cst_types_.find( type_name );
129  if ( iter != cst_types_.end() ) {
130  return iter->second;
131  } else {
132 
133  using std::string;
134  using utility::vector1;
135  string msg("ConstraintFactory::get_creator: ");
136  msg += type_name + " does not name a known ConstraintType --> " +
137  "check spelling or register new Constraint type in ConstraintFactory!";
138 
139  msg += "known types are:\n";
141  for ( vector1< string >::const_iterator it = types.begin(), end = types.end(); it != end; ++it ) {
142  msg += *it + "\n";
143  }
144 
145  utility_exit_with_message( msg );
146  }
147  return 0;
148 }
149 
150 
151 /*ConstraintFactory::ConstraintFactory(void) {
152  // initialization of functions which this factory knows how to instantiate
153  add_type( new AtomPairConstraint( id::AtomID(), id::AtomID(), NULL ) );
154  add_type( new AngleConstraint( id::AtomID(), id::AtomID(), id::AtomID(), NULL ) );
155  add_type( new DihedralConstraint( id::AtomID(), id::AtomID(), id::AtomID(), id::AtomID(), NULL ) );
156  add_type( new InterfaceConstraint( id::AtomID(), NULL ) );
157  add_type( new BindingSiteConstraint() );
158  add_type( new BindingSiteConstraintResidues() );
159  add_type( new BigBinConstraint() );
160  add_type( new MultiConstraint() );
161  add_type( new AmbiguousConstraint() );
162  add_type( new KofNConstraint() );
163  add_type( new CoordinateConstraint() );
164  add_type( new LocalCoordinateConstraint() );
165  add_type( new DunbrackConstraint() );
166  add_type( new AmbiguousNMRDistanceConstraint() );
167  add_type( new AmbiguousNMRConstraint() );
168  add_type( new ResidueTypeConstraint() );
169 
170  add_type( new AmbiguousConstraint() );
171  add_type( new AmbiguousNMRConstraint() );
172  add_type( new AmbiguousNMRDistanceConstraint() );
173  add_type( new AngleConstraint( id::AtomID(), id::AtomID(), id::AtomID(), NULL ) );
174  add_type( new AtomPairConstraint( id::AtomID(), id::AtomID(), NULL ) );
175  add_type( new BigBinConstraint() );
176  add_type( new BindingSiteConstraint() );
177  add_type( new BindingSiteConstraintResidues() );
178  add_type( new CoordinateConstraint() );
179  add_type( new DihedralConstraint( id::AtomID(), id::AtomID(), id::AtomID(), id::AtomID(), NULL ) );
180  add_type( new DunbrackConstraint() );
181  add_type( new KofNConstraint() );
182  add_type( new LocalCoordinateConstraint() );
183  add_type( new MultiConstraint() );
184 
185 
186 }*/
187 
188 } // constraints
189 } // scoring
190 } // core