Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

DataSet* data_set_init ( gchar *  fname  ) 

Create a DataSet structure and initialise it to some default values.

Parameters:
fname The name to be given to the DataSet.
Returns:
A pointer to an empty DataSet initialised to default values.
Note:
The returned DataSet must be freed.

Definition at line 44 of file read_data.c.

References _DataSet::cmpt_set, _DataSet::dir, _DataSet::fname, _DataSet::frame, global_working_directory, _DataSet::name, _DataSet::nframes, _DataSet::scale, _DataSet::scale_entry_field, _DataSet::type, _DataSet::x_range, and _DataSet::y_range.

Referenced by dataset_derivative(), dataset_read_from_file(), and dataset_read_subtract_files().

{
  DataSet* data_set;
  gchar* tmp;

  data_set = g_malloc(sizeof(DataSet));
  
  data_set->name=NULL;
  data_set->fname=NULL;
  data_set->dir=NULL;
  
  data_set->type = YG_DATAFILE;

  if (fname != NULL)
    {
      data_set->dir = g_dirname(tmp=g_strdup(fname));
      g_free(tmp);
      tmp=NULL;
      if (g_strcasecmp(fname, INTERNAL_STDIN_STR))
        data_set->name = g_strdup(g_basename(tmp=g_strdup(fname)));
      else
        data_set->name = "stdin";
      if (tmp != NULL)
        g_free(tmp);
      if (!g_path_is_absolute(fname) &&
           g_strcasecmp(fname, INTERNAL_STDIN_STR))
        data_set->fname = g_strjoin(G_DIR_SEPARATOR_S,
                                    global_working_directory, fname, NULL);
      else
        data_set->fname = g_strdup(fname);
    }
  else
    {
      data_set->dir = NULL;
      data_set->name = NULL;
      data_set->fname = NULL;
    }

  data_set->nframes = 0;
  data_set->x_range[0] = G_MAXDOUBLE;
  data_set->x_range[1] = -G_MAXDOUBLE;
  data_set->y_range[0] = G_MAXDOUBLE;
  data_set->y_range[1] = -G_MAXDOUBLE;
  data_set->scale = DEFAULT_DATA_SCALE_FACTOR;
  data_set->frame = g_array_new(FALSE, FALSE, sizeof(Frame*));
  data_set->cmpt_set = g_array_new(FALSE, FALSE, sizeof(gint));
  data_set->scale_entry_field = NULL;

  return data_set;
}


Generated by  Doxygen 1.6.0   Back to index