Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Constraint.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 Constraints.cc
11 ///
12 /// @brief Constraints class for the schema generator framework
13 /// @author Tim Jacobs
14 
17 #include <platform/types.hh>
18 
19 #include <string>
20 #include <sstream>
21 
22 namespace basic {
23 namespace database {
24 namespace schema_generator {
25 
26 /// @details Auto-generated virtual destructor
28 
29 using std::string;
30 using std::stringstream;
31 using platform::Size;
32 using platform::Real;
33 
34 
36  Column column
37 ) :
38  columns_()
39 {
40  columns_.push_back(column);
41 }
42 
44  Columns columns
45 ) :
46  columns_(columns)
47 {}
48 
49 
51  Column column
52 ) :
53  Constraint(column)
54 {}
55 
57  Columns columns
58 ) :
59  Constraint(columns)
60 {}
61 
62 std::string
64  utility::sql_database::sessionOP /*database_session*/
65 ) const {
66  stringstream constraint;
67 
68  constraint << "UNIQUE (";
69 
70  for ( Size i=1; i<=columns_.size(); ++i ) {
71  if ( i!=1 ) {
72  constraint << ", ";
73  }
74  constraint << columns_[i].name();
75  }
76  constraint << ")";
77  return constraint.str();
78 }
79 
80 
82  Column column,
84 ) :
85  Constraint(column),
86  value_(value)
87 {}
88 
89 std::string
91  utility::sql_database::sessionOP /*database_session*/
92 ) const {
93  stringstream constraint;
94 
95  assert(columns_.size() == 1);
96 
97  constraint << "CONSTRAINT " << columns_[1].name() << "_greater_than CHECK ";
98  constraint << "(" << columns_[1].name() << " >= " << value_ << ")";
99  return constraint.str();
100 }
101 
102 
103 } // schema_generator
104 } // namespace database
105 } // namespace utility
106 
double Real
Definition: types.hh:45
tuple database
member1 value
Definition: Tag.cc:296
virtual ~Constraint()
Automatically generated virtual destructor for class deriving directly from ReferenceCount.
Definition: Constraint.cc:27
GreaterThanConstraint(Column column, platform::Real value)
Definition: Constraint.cc:81
Column class for the schema generator framework.
std::string print(utility::sql_database::sessionOP) const
Definition: Constraint.cc:63
std::size_t Size
Definition: types.hh:37
std::string print(utility::sql_database::sessionOP) const
Definition: Constraint.cc:90
pointer::shared_ptr< session > sessionOP