Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
comparative_modeling
AlignmentID.hh
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 protocols/id/AlignmentID.hh
11
/// @author James Thompson
12
13
14
#ifndef INCLUDED_protocols_comparative_modeling_AlignmentID_hh
15
#define INCLUDED_protocols_comparative_modeling_AlignmentID_hh
16
17
#include <
core/types.hh
>
18
19
#include <ObjexxFCL/string.functions.hh>
20
21
#include <sstream>
22
23
24
namespace
protocols {
25
namespace
id {
26
27
/// @brief Unique template identifier class
28
class
AlignmentID
29
{
30
31
public
:
// Creation
32
33
/// @brief Default constructor
34
inline
35
AlignmentID
() :
36
align_idx_
( 0 ),
37
template_name_
(
"empty"
)
38
{}
39
40
/// @brief Copy constructor
41
inline
42
AlignmentID
(
AlignmentID
const
& src ) :
43
align_idx_
( src.
align_idx
() ),
44
template_name_
( src.
template_name
() )
45
{}
46
47
/// @brief Property constructor
48
inline
49
AlignmentID
(
50
core::Size
const
align_idx_in,
51
std::string
const
template_name_in
52
) :
53
align_idx_
( align_idx_in ),
54
template_name_
( template_name_in )
55
{}
56
57
public
:
// Properties
58
59
inline
60
std::string
61
template_name
()
const
{
62
return
template_name_
;
63
}
64
65
inline
66
std::string
&
67
template_name
() {
68
return
template_name_
;
69
}
70
71
inline
72
core::Size
73
align_idx
()
const
{
74
return
align_idx_
;
75
}
76
77
inline
78
core::Size
&
79
align_idx
() {
80
return
align_idx_
;
81
}
82
83
void
84
template_name
(
std::string
const
& name ) {
85
template_name_
= name;
86
}
87
88
void
89
align_idx
(
core::Size
const
& idx ) {
90
align_idx_
= idx;
91
}
92
93
/// @brief Is this id valid?
94
inline
95
bool
96
valid
()
const
{
97
return
(
align_idx_
> 0 ) && (
template_name_
!=
""
);
98
}
99
100
inline
101
std::string
to_string
()
const
{
102
std::ostringstream out;
103
out <<
template_name
() <<
"_"
<<
align_idx
();
104
return
out.str();
105
}
106
107
public
:
// Friends
108
109
friend
110
std::ostream &
111
operator <<
(
112
std::ostream & os,
113
AlignmentID
const
& a
114
) {
115
os << a.
to_string
();
116
return
os;
117
}
118
119
friend
120
std::istream &
121
operator >>
(
122
std::istream & is,
123
AlignmentID
& a
124
) {
125
using
std::string
;
126
127
string
tag;
128
is >> tag;
129
string::size_type pos = tag.find_first_of(
"_"
, 0);
130
string
t_name = tag.substr(0,pos);
131
string
index = tag.substr(pos);
132
133
a.
template_name
( t_name );
134
a.
align_idx
( static_cast< core::Size > (ObjexxFCL::int_of( index )) );
135
136
return
is;
137
}
138
139
/// @brief a and b are the same atom
140
friend
141
inline
142
bool
143
operator ==
(
144
AlignmentID
const
& a,
145
AlignmentID
const
&
b
146
) {
147
return
a.
align_idx
() == b.
align_idx
() &&
148
a.
template_name
() == b.
template_name
();
149
}
150
151
/// @brief a and b are different atom
152
friend
153
inline
154
bool
155
operator !=
(
156
AlignmentID
const
& a,
157
AlignmentID
const
&
b
158
) {
159
return
!( a ==
b
);
160
}
161
162
/// @brief a is LOWER than b (e.g., first by smaller template name then
163
/// by smaller alignment index)
164
friend
165
inline
166
bool
167
operator <
(
168
AlignmentID
const
& a,
169
AlignmentID
const
&
b
170
) {
171
return
( a.
template_name_
< b.
template_name_
||
172
( a.
template_name_
== b.
template_name_
&& a.
align_idx_
< b.
align_idx_
) );
173
}
174
175
private
:
// Fields
176
/// @brief numerical identifier for Nth alignment to this template
177
core::Size
align_idx_
;
178
179
/// @brief template name
180
std::string
template_name_
;
181
};
// AlignmentID
182
183
}
// namespace id
184
}
// namespace protocols
185
186
187
#endif // INCLUDED_protocols_comparative_modeling_AlignmentID_HH
Generated on Sat Jun 1 2013 11:45:23 for Rosetta 3.5 by
1.8.4