[cairo-commit] roadster/src mainwindow.c, 1.6, 1.7 track.c, NONE, 1.1 track.h, NONE, 1.1 track.o, NONE, 1.1

Ian McIntosh commit at pdx.freedesktop.org
Fri Feb 25 20:48:42 PST 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv2249/src

Modified Files:
	mainwindow.c 
Added Files:
	track.c track.h track.o 
Log Message:
	* track.c:
	* track.h: Actually include these files.


Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mainwindow.c	26 Feb 2005 04:41:40 -0000	1.6
+++ mainwindow.c	26 Feb 2005 04:48:39 -0000	1.7
@@ -80,7 +80,6 @@
 	kToolZoom = 1,
 } EToolType;
 
-
 // Prototypes
 gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
 gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data);

--- NEW FILE: track.c ---
/***************************************************************************
 *            track.c
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <gnome.h>
#include "map.h"
#include "pointstring.h"
#include "point.h"

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

typedef struct track {
	pointstring_t* m_pPointString;
	gint m_nID;
} track_t;

struct {
	GHashTable* m_pTracksHash;
	GMemChunk* g_pTrackChunkAllocator;
} g_Tracks;

void track_init(void)
{
	g_Tracks.m_pTracksHash = g_hash_table_new(g_int_hash, g_int_equal);
	g_Tracks.g_pTrackChunkAllocator = g_mem_chunk_new("track chunk allocator",
			sizeof(track_t), 1000, G_ALLOC_AND_FREE);
	g_return_if_fail(g_Tracks.g_pTrackChunkAllocator != NULL);
}

gint track_new()
{
	// insert into DB to get a unique ID
	gint nID = 1;

	// alloce structure for it
	track_t* pNew = g_mem_chunk_alloc0(g_Tracks.g_pTrackChunkAllocator);
	pNew->m_nID = nID;
	pointstring_alloc(&pNew->m_pPointString);

	// save in hash for fast lookups
	g_hash_table_insert(g_Tracks.m_pTracksHash, &pNew->m_nID, pNew);

	return nID;
}

void track_add_point(gint nTrackID, const mappoint_t *pPoint)
{
	g_print("adding point to track %d\n", nTrackID);

	track_t* pTrack = g_hash_table_lookup(g_Tracks.m_pTracksHash, &nTrackID);
	if(pTrack == NULL) {
		// lookup in DB?

		g_warning("not adding to track %d\n", nTrackID);
		return;
	}

	pointstring_append_point(pTrack->m_pPointString, pPoint);
}

const pointstring_t* track_get_pointstring(gint nID)
{
	track_t* pTrack = g_hash_table_lookup(g_Tracks.m_pTracksHash, &nID);
	if(pTrack != NULL) {
		return pTrack->m_pPointString;
	}
	return NULL;
}

--- NEW FILE: track.h ---
/***************************************************************************
 *            track.h
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _TRACK_H_
#define _TRACK_H_

void track_add_point(gint nTrackID, const mappoint_t *pPoint);
void track_init(void);
gint track_new();
const pointstring_t* track_get_pointstring(gint nID);

#endif

--- NEW FILE: track.o ---
(This appears to be a binary file; contents omitted.)




More information about the cairo-commit mailing list