Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/src/lib/include/diderot/world.hxx
ViewVC logotype

View of /branches/vis15/src/lib/include/diderot/world.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3988 - (download) (as text) (annotate)
Fri Jun 17 17:26:51 2016 UTC (3 years, 1 month ago) by jhr
File size: 2820 byte(s)
working on merge
/*! \file world.hxx
 *
 * \author John Reppy
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 */

#ifndef _DIDEROT_WORLD_HXX_
#define _DIDEROT_WORLD_HXX_

#include <iostream>
#include <teem/biff.h>
#include <teem/nrrd.h>

namespace diderot {

    // stages of execution of a program
    //
    enum execution_state {
	POST_NEW = 0,                       // world allocated, but not initialized
	POST_INIT = 1,                      // Init function has been called
	POST_INITIALLY = 2,                 // globals and strands have been initialized
	RUNNING = 3,                        // program is running
	DONE = 4                            // program has terminated
    };

    // the base struct for the world type
    //
    struct world_base {
	std::string         _name;          // the program name
	biffMsg             *_errors;       // holds error messages (if any)
	execution_state     _stage;         // current stage of program execution
	bool                _verbose;       // true if running in verbose mode
	bool                _is_array;      // are the strands in an array or collection?
	uint32_t            _naxes;         // depth of iteration nesting
	uint32_t            *_base;         // nAxes array of base indices
	uint32_t            *_size;         // nAxes array of iteration sizes
	uint32_t            _nstrands;      // number of strands in the world
	std::ostream	    *_output;       // where to direct output to (default is cout).
	double              _run_time;      // total time in seconds spent running Diderot code

	world_base (std::string const &name, bool isArr, int nAxes)
	    : _name(name), _errors(biffMsgNew("DIDEROT")), _stage(POST_NEW),
	      _verbose(false), _is_array(isArr), _naxes(nAxes),
	      _base(new uint32_t[nAxes]), _size(new uint32_t[nAxes]),
	      _nstrands(0), _output(nullptr), _run_time(0)
	{ }

	~world_base ()
	{
	    biffMsgNix (this->_errors);
	    delete[] this->_base;
	    delete[] this->_size;
	    if (this->_output != nullptr) {
		delete this->_output;
	    }
	}

	std::ostream & output()
	{
	    return (this->_output == nullptr) ? std::cout : *this->_output;
	}

	void error (const char *fmt, ...);

	Nrrd *load_nrrd_file (std::string const &filename);

      //! Check that a nrrd has the expected structure for loading into a dynamic sequence
      //! \param nin the nrrd to check
      //! \param nDims the number of dimensions in the sequence elements
      //! \param dims the array of sequence element dimensions
      //! \return the number of values per element, or zero on error
	uint32_t check_nrrd (Nrrd *nin, uint32_t nDims, uint32_t *dims);

    };

} // namespace diderot

#endif // !_DIDEROT_WORLD_HXX_

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0