Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResFilterFactory.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/pack/task/operation/ResFilterFactory.cc
11 /// @brief
12 /// @author ashworth
13 
16 
17 // AUTO-REMOVED #include <core/pack/task/operation/ResFilters.hh>
18 
19 #include <utility/exit.hh> // runtime_assert, utility_exit_with_message
20 // AUTO-REMOVED #include <utility/tag/Tag.hh>
21 
23 #include <utility/vector0.hh>
24 #include <utility/vector1.hh>
25 
26 namespace core {
27 namespace pack {
28 namespace task {
29 namespace operation {
30 
31 // special singleton functions
32 // initialize
33 ResFilterFactory * ResFilterFactory::instance_( 0 );
34 // get pointer to singleton
36 {
37  if ( ! instance_ ) {
39  }
40  return instance_;
41 }
42 
45 
46 void
48 {
49  add_creator( creator );
50 }
51 
52 ///@brief add a ResFilter prototype, using its default type name as the map key
53 void
55 {
56  runtime_assert( creator );
57  filter_creator_map_[ creator->keyname() ] = creator;
58 }
59 
60 bool ResFilterFactory::has_type( std::string const & type ) const
61 {
62  return ( filter_creator_map_.find( type ) != filter_creator_map_.end() );
63 }
64 
65 ///@brief return new ResFilter by key lookup in filter_creator_map_ (new ResFilter parses Tag if provided)
68  std::string const & type,
69  TagPtr tag /* = boost::shared_ptr< Tag >() */
70 ) const
71 {
72  ResFilterCreatorMap::const_iterator iter( filter_creator_map_.find( type ) );
73  if ( iter != filter_creator_map_.end() ) {
74  ResFilterOP filter( iter->second->create_res_filter() );
75  // parse tag if tag pointer is pointing to one
76  if ( tag.get() != NULL ) filter->parse_tag( tag );
77  return filter;
78  } else {
79  utility_exit_with_message( type + " is not known to the ResFilterFactory. Was its ResFilterCreator class registered at initialization?" );
80  return NULL;
81  }
82 }
83 
84 } //namespace operation
85 } //namespace task
86 } //namespace pack
87 } //namespace core