-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexample_interface.h
More file actions
216 lines (180 loc) · 8.06 KB
/
Copy pathexample_interface.h
File metadata and controls
216 lines (180 loc) · 8.06 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// (c) Copyright BCL @ Vanderbilt University 2014
// (c) BCL Homepage: http://www.meilerlab.org/bclcommons
// (c) BCL Code Repository: https://github.com/BCLCommons/bcl
// (c)
// (c) The BioChemical Library (BCL) was originally developed by contributing members of the Meiler Lab @ Vanderbilt University.
// (c)
// (c) The BCL is now made available as an open-source software package distributed under the permissive MIT license,
// (c) developed and maintained by the Meiler Lab at Vanderbilt University and contributing members of the BCL Commons.
// (c)
// (c) External code contributions to the BCL are welcome. Please visit the BCL Commons GitHub page for information on how you can contribute.
// (c)
// (c) This file is part of the BCL software suite and is made available under the MIT license.
// (c)
#ifndef EXAMPLE_INTERFACE_H_
#define EXAMPLE_INTERFACE_H_
// include forward header of this class
// include other forward headers - sorted alphabetically
// includes from bcl - sorted alphabetically
#include "util/bcl_util_object_interface.h"
// external includes - sorted alphabetically
namespace bcl
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//! @brief Interface for all examples
//! every example class is derived from that interface. The Run function is like a main, that performs
//! different functionality test on the class the example is written for.
//! It provides an AddExamplePathToFilename function, that - depending on the environment - adds a path
//! where all example files live and new files should be written to.
//!
//! Each example is then added to the ExampleClass - and stored with a ShPtr to an ExampleInterface.
//! The execution of all examples is handled by the ExampleClass
//!
//! @author woetzen, karakam,
//!
//! @date August 2007
//!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ExampleInterface :
public util::ObjectInterface
{
public:
//////////
// data //
//////////
//! enumerator that defines the different example input paths
enum ExampleInputTypes
{
e_Biology,
e_Chemistry,
e_Cluster,
e_Density,
e_Descriptor,
e_Fold,
e_Graphics,
e_Math,
e_Mc,
e_Model,
e_Opti,
e_Quality,
e_Random,
e_Restraint,
e_Scorestat,
s_NumberExampleInputTypes
};
//! paths associated with each enum
static const std::string s_ExampleInputPaths[];
//! static string to hold the input folder
static const std::string s_ExampleInputFolderName;
//! static string to hold the output folder
static const std::string s_ExampleOutputFolderName;
//! static string to hold the BCL Object folder
static const std::string s_ExampleBclObjectFolderName;
//! static string to hold the source code output folder name
static const std::string s_ExampleSourceCodeFolderName;
//! static string to hold default extension for bcl object files
static const std::string s_ExampleBclObjectExtension;
////////////////
// operations //
////////////////
//! @brief virtual run routine
//! this is performing the execution of the example and needs to be overwritten by each derived example
virtual int Run() const = 0;
//////////////////////
// input and output //
//////////////////////
//! @brief read from std::istream
//! @param ISTREAM input stream
//! @return istream which was read from
virtual std::istream &Read( std::istream &ISTREAM);
//! @brief write to std::ostream
//! @param OSTREAM output stream to write to
//! @param INDENT number of indentations
//! @return output stream which was written to
virtual std::ostream &Write( std::ostream &OSTREAM, const size_t INDENT) const;
//////////////////////
// helper functions //
//////////////////////
//! @brief returns the input path to given filename for the given input type
//! @param EXAMPLE_INPUT_TYPE type of example input
//! @param FILENAME input filename
//! @return the input path to given filename for the given input type
static std::string AddExampleInputPathToFilename
(
const ExampleInputTypes &EXAMPLE_INPUT_TYPE,
const std::string &FILENAME
);
//! @brief adds the example output path to filename for given sample object
//! @param OBJECT object for which the example this function is being called was written for
//! @param FILENAME name of the file to be outputted
static std::string AddExampleOutputPathToFilename
(
const util::ObjectInterface &OBJECT,
const std::string &FILENAME
);
//! @brief adds the example output path to filename for given namespace identifier
//! @param NAMESPACE_IDENTIFIER namespace identifier of the object to which this example file belongs to
//! @param FILENAME name of the file to be outputted
static std::string AddExampleOutputPathToFilename
(
const std::string &NAMESPACE_IDENTIFIER,
const std::string &FILENAME
);
//! @brief returns the bcl object output path for the given object
//! @param OBJECT object to be outputted
//! @param EXTENSION extension of file ".bcl" by default
//! @return the bcl object output path for the given namespace and the object
static std::string GetExampleOutputPathForBCLObject
(
const util::ObjectInterface &OBJECT,
const std::string &EXTENSION = s_ExampleBclObjectExtension
);
//! @brief reads the given bcl object from associated example path
//! @param OBJECT object to be read
//! @param EXTENSION extension of file ".bcl" by default
//! @return true on success
bool ReadBCLObject( util::ObjectInterface &OBJECT, const std::string &EXTENSION = s_ExampleBclObjectExtension) const;
//! @brief reads the given bcl object from associated example path
//! @param OBJECT object to be read
//! @param PATH path where the object to be read lives
//! @return true on success
bool ReadBCLObjectfromPath
(
util::ObjectInterface &OBJECT,
const std::string &PATH = s_ExampleBclObjectFolderName
) const;
//! @brief writes the given bcl object to associated example path
//! @param EXTENSION extension of file ".bcl" by default
//! @param OBJECT object to be written
//! @return true on success
bool WriteBCLObject( const util::ObjectInterface &OBJECT, const std::string &EXTENSION = s_ExampleBclObjectExtension) const;
//! @brief tests whether Write functions for two objects return different strings
//! @param OBJECT An object to be tested
//! @param DIFF_OBJECT Any other object
//! @return false if OBJECT and DIFF_OBJECT are identical
static bool TestBCLObjectOutputDiffers
(
const util::ObjectInterface &OBJECT,
const util::ObjectInterface &DIFF_OBJECT
);
//! @brief Checks whether the output from one object can be read into another object
//! such that both objects return the same string when written out
//! @param OBJECT Any object
//! @param OBJECT_STORAGE an object (ideally a blank object)
//! @return false if OBJECT was not written to or read into OBJECT_STORAGE symmetrically
//! @note there is no way for this function to know whether the outputs are equivalent in some sense;
//! @note this function is useful when there is a one-to-one mapping between output and object
//! @note it cannot help you if the outputs do not have to be identical (e.g. writing addresses of objects)
static bool TestBCLObjectIOForSymmetry
(
const util::ObjectInterface &OBJECT,
const util::ObjectInterface &OBJECT_STORAGE
);
//! @brief function for adding path to filename
//! @param FILENAME used filename
//! @param EXTENSION used extension, default is empty
//! @return filename with path and extension
static std::string AddExamplePathToFilename( const std::string &FILENAME, const std::string &EXTENSION = "");
}; // class ExampleInterface
} // namespace bcl
#endif //EXAMPLE_INTERFACE_H_