7.2. Adding a file format to SpecTcl

Adding a format is conceptually simple. You must

The key methods you must implement in your formatter class are:

 virtual   CSpectrum* Read (std::istream& rStream, 
			    ParameterDictionary& rDict);
 virtual   void Write (std::ostream& rStream, CSpectrum& rSpectrum,
		       ParameterDictionary& rDict);

Read is expected to read a spectrum from the input stream rStream and return a dynamically allocated spectrum. rDict is the parameter dictionary, which can be used to take any metadata supplied by the file about parameters and spectrum types to know how to construct the spectrum.

Similarly, Write takes a CSpectrum object and is expected to serialize it to an output stream rStream. rDict is the parameter dictionary and can be used by the method to generate any metadata needed to describe the spectrum.