File: TestSpectrumView.cxx

package info (click to toggle)
clam 1.4.0-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,836 kB
  • ctags: 20,981
  • sloc: cpp: 92,504; python: 9,721; ansic: 1,602; xml: 444; sh: 239; makefile: 153; perl: 54; asm: 15
file content (164 lines) | stat: -rw-r--r-- 4,243 bytes parent folder | download | duplicates (2)
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
#include "Spectrum.hxx"
#include "LogMagSpectrumAdapter.hxx"
#include "StdioSpectrumPresentation.hxx"
#include "XMLStorage.hxx"
#include "Err.hxx"
#include <iostream>
#include <exception>
#include <string>

using CLAM::Spectrum;
using CLAMVM::LogMagSpectrumAdapter;
using CLAMVM::StdioSpectrumPresentation;
using CLAM::XMLStorage;

static const char* sPathToData= "./Datasets/";


bool TestPureComplexUseCase(LogMagSpectrumAdapter& view, StdioSpectrumPresentation& presentation )
{
		XMLStorage  x;
		Spectrum    specObj;

		std::string filename = "SpectrumOnlyComplex.xml";
		std::string pathToFile = sPathToData;

		pathToFile+=filename;


		x.Restore( specObj, pathToFile );  // Spectrum has been incorporated into the system
		
		view.BindTo( specObj );

		view.Publish();
		presentation.Show();

		return true;

}

bool TestPurePolarUseCase(LogMagSpectrumAdapter& view, StdioSpectrumPresentation& presentation)
{
		XMLStorage  x;
		Spectrum    specObj;

		std::string filename = "SpectrumOnlyPolar.xml";
		std::string pathToFile = sPathToData;

		pathToFile+=filename;


		x.Restore( specObj, pathToFile );  // Spectrum has been incorporated into the system
		
		view.BindTo( specObj );

		view.Publish();
		presentation.Show();

		return true;

}

bool TestPureBPFUseCase( LogMagSpectrumAdapter& view, StdioSpectrumPresentation& presentation )
{
		XMLStorage  x;
		Spectrum    specObj;

		std::string filename = "SpectrumOnlyBPF.xml";
		std::string pathToFile = sPathToData;

		pathToFile+=filename;


		x.Restore( specObj, pathToFile );  // Spectrum has been incorporated into the system
		
		view.BindTo( specObj );

		view.Publish();
		presentation.Show();

		return true;
}

bool TestBasicUseCase( LogMagSpectrumAdapter& view, StdioSpectrumPresentation& presentation )
{
		XMLStorage  x;
		Spectrum    specObj;

		std::string filename = "Spectrum.xml";
		std::string pathToFile = sPathToData;

		pathToFile+=filename;


		x.Restore( specObj, pathToFile );  // Spectrum has been incorporated into the system
		
		view.BindTo( specObj );

		view.Publish();
		presentation.Show();

		return true;
}

int main( int argc, char** argv )
{
		try
		{
				LogMagSpectrumAdapter        view;
				StdioSpectrumPresentation presentation;

				presentation.AttachTo( view );

				std::cerr << "BASIC SPECTRUM VIEW USE CASE TEST LAUNCHED" << std::endl;
				if ( !TestBasicUseCase( view, presentation ) )
						std::cerr << "Basic Use case Test...... FAILED!" << std::endl;
				else
						std::cerr << "Basic Use case Test...... Passed!" << std::endl;

				std::cerr << "ONLY COMPLEX BUFFER ON SPECTRUM OBJECT SPECTRUM VIEW USE CASE TEST LAUNCHED" << std::endl;
				if ( !TestPureComplexUseCase( view, presentation ) )
						std::cerr << "Observing spectrum with only complex buffer use case Test...... FAILED!" << std::endl;
				else
						std::cerr << "Observing spectrum with only complex buffer use case Test...... Passed!" << std::endl;

				std::cerr << "ONLY POLAR BUFFER ON SPECTRUM OBJECT SPECTRUM VIEW USE CASE TEST LAUNCHED" << std::endl;
				if ( !TestPurePolarUseCase( view, presentation ) )
						std::cerr << "Observing spectrum with only polar buffer use case Test...... FAILED!" << std::endl;
				else
						std::cerr << "Observing spectrum with only polar buffer use case Test...... Passed!" << std::endl;

				std::cerr << "ONLY BPF BUFFERS ON SPECTRUM OBJECT SPECTRUM VIEW USE CASE TEST LAUNCHED" << std::endl;
				if ( !TestPureBPFUseCase( view, presentation ) )
						std::cerr << "Observing spectrum with only BPF buffers use case Test...... FAILED!" << std::endl;
				else
						std::cerr << "Observing spectrum with only BPF buffers use case Test...... Passed!" << std::endl;

				

		}
		catch ( CLAM::Err& e )
		{
				std::cerr << "A CLAM controlled error has occured" << std::endl;
				e.Print();
				std::cerr << "<==== END OF ERROR MESSAGE" << std::endl;

				return -1;
		}
		catch( std::exception& e )
		{
				std::cerr << "An standard library error has occured" << std::endl;
				std::cerr << e.what() << std::endl;
				std::cerr << "<==== END OF ERROR MESSAGE" << std::endl;

				return -1;
		}
		catch( ... )
		{
				std::cerr << "An unknown error has occured!" << std::endl;
				return -1;
		}

		return 0;		
}