kptraininglog

Name

kptraininglog -- A database that is used to handle all training data.

Synopsis



enum        KPTrainingLogError;
GQuark      kp_training_log_error_quark     (void);
#define     KP_TRAINING_LOG_ERROR
KPTrainingLog* kp_training_log_new          (void);
KPTrainingLog* kp_training_log_new_from_file
                                            (const gchar *file);
void        kp_training_log_destroy         (KPTrainingLog *log);
gboolean    kp_training_log_save            (KPTrainingLog *log,
                                             const gchar *file,
                                             GError **error);
gboolean    kp_training_log_create_html_stats
                                            (KPTrainingLog *log,
                                             const gchar *output_dir,
                                             GError **error);
gboolean    kp_training_log_add             (KPTrainingLog *log,
                                             KPCalendarEntry *entry);
gboolean    kp_training_log_add_from_file   (KPTrainingLog *log,
                                             const gchar *file,
                                             GError **error);
gboolean    kp_training_log_remove          (KPTrainingLog *log,
                                             KPCalendarEntry *entry);
void        kp_training_log_remove_mark     (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y,
                                             const gchar *mark);
void        kp_training_log_remove_month    (KPTrainingLog *log,
                                             guint y,
                                             guint m);
void        kp_training_log_remove_day      (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y);
KPCalendarEntry* kp_training_log_get_entry  (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y,
                                             const gchar *mark);
TYear*      kp_training_log_get_year        (KPTrainingLog *log,
                                             guint year);
guint       kp_training_log_get_size        (KPTrainingLog *log);
GList*      kp_training_log_get_all_entries (KPTrainingLog *log);
GList*      kp_training_log_get_all_entries_between
                                            (KPTrainingLog *log,
                                             GDate *start,
                                             GDate *end,
                                             GList **sports);
gdouble**   kp_training_log_get_workout_params_between
                                            (KPTrainingLog *log,
                                             KPTrainingLogDataModemode,
                                             const gchar *sport,
                                             const gchar *param,
                                             GDate *start,
                                             GDate *end,
                                             guint *days_between);
gdouble**   kp_training_log_get_workout_params_year
                                            (KPTrainingLog *log,
                                             const gchar *param,
                                             guint year,
                                             guint *days_between);
GList*      kp_training_log_get_day         (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y);
GList*      kp_training_log_get_month       (KPTrainingLog *log,
                                             gint year,
                                             gint month);
gboolean    kp_training_log_is_modified     (KPTrainingLog *log);
gdouble**   kp_training_log_get_month_as_chart_data
                                            (KPTrainingLog *log,
                                             guint year,
                                             guint month,
                                             guint month_len,
                                             const gchar *param);
gdouble     kp_training_log_get_week_total  (KPTrainingLog *log,
                                             GDate *date,
                                             const gchar *param);
gdouble     kp_training_log_get_param_day   (KPTrainingLog *log,
                                             GDate *date,
                                             const gchar *param);
void        kp_training_log_foreach         (KPTrainingLog *log,
                                             GFunc func,
                                             gpointer data);
GtkTreeStore* kp_training_log_get_data_as_tree_store
                                            (KPTrainingLog *log);
void        kp_training_log_dump            (KPTrainingLog *log);

Description

Details

enum KPTrainingLogError

typedef enum
{
  KP_TRAINING_LOG_SAVE_HTML_ERROR,
  KP_TRAINING_LOG_SAVE_ERROR,
  KP_TRAINING_LOG_OPEN_ERROR,
  KP_TRAINING_LOG_INTERNAL_ERROR
} KPTrainingLogError;


kp_training_log_error_quark ()

GQuark      kp_training_log_error_quark     (void);

Returns :


KP_TRAINING_LOG_ERROR

#define         KP_TRAINING_LOG_ERROR kp_training_log_error_quark()


kp_training_log_new ()

KPTrainingLog* kp_training_log_new          (void);

Create a new instance of KPTrainingLog.

Returns :

A KPTrainingLog


kp_training_log_new_from_file ()

KPTrainingLog* kp_training_log_new_from_file
                                            (const gchar *file);

file :

Returns :


kp_training_log_destroy ()

void        kp_training_log_destroy         (KPTrainingLog *log);

log :


kp_training_log_save ()

gboolean    kp_training_log_save            (KPTrainingLog *log,
                                             const gchar *file,
                                             GError **error);

Just save the contents of the log to the file specified by the file.

log :

A KPTrainingLog

file :

File to save log into

error :

Returns :

TRUE if successful or FALSE otherwise.


kp_training_log_create_html_stats ()

gboolean    kp_training_log_create_html_stats
                                            (KPTrainingLog *log,
                                             const gchar *output_dir,
                                             GError **error);

Generate HTML statistics from data.

log :

A KPTrainingLog

output_dir :

Directory to output the HTML files

error :

location to store possible error

Returns :

TRUE if successful and FALSE otherwise.


kp_training_log_add ()

gboolean    kp_training_log_add             (KPTrainingLog *log,
                                             KPCalendarEntry *entry);

Just add the calendar entry to the log.

log :

A KPTrainingLog

entry :

A KPCalendarEntry to add to the log.

Returns :

TRUE if the entry was added and FALSE if some error occurred.


kp_training_log_add_from_file ()

gboolean    kp_training_log_add_from_file   (KPTrainingLog *log,
                                             const gchar *file,
                                             GError **error);

Add all the entries from the log specified by the file to the existing log.

log :

A KPTrainingLog

file :

The name of the log file

error :

Returns :

TRUE if successful and FALSE otherwise.


kp_training_log_remove ()

gboolean    kp_training_log_remove          (KPTrainingLog *log,
                                             KPCalendarEntry *entry);

Just remove the calendar entry from the log.

log :

A KPTrainingLog

entry :

A KPCalendarEntry to remove from the log.

Returns :

TRUE if the entry was removed and FALSE if some error occurred.


kp_training_log_remove_mark ()

void        kp_training_log_remove_mark     (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y,
                                             const gchar *mark);

Removes the mark from the log.

log :

a KPTrainingLog

d :

the day

m :

the month

y :

the year

mark :

the mark to remove


kp_training_log_remove_month ()

void        kp_training_log_remove_month    (KPTrainingLog *log,
                                             guint y,
                                             guint m);

Remove all entries in a month.

log :

A KPTrainingLog

y :

the day

m :

the month


kp_training_log_remove_day ()

void        kp_training_log_remove_day      (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y);

Remove all entries of a day.

log :

d :

the day

m :

the month

y :

the year


kp_training_log_get_entry ()

KPCalendarEntry* kp_training_log_get_entry  (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y,
                                             const gchar *mark);

Get a CalendarEntry. DMY must be valid.

log :

A KPTrainingLog

d :

Number of day between 1 and 31

m :

Number of month between 1 and 12

y :

Number of in format yyyy

mark :

Returns :

A KPCalendarEntry or NULL if there is no such entry in the log.


kp_training_log_get_year ()

TYear*      kp_training_log_get_year        (KPTrainingLog *log,
                                             guint year);

Get a year-structure for any year. If there aren't any kp_workouts with a date in the given year in the log, NULL will be returned.

Otherwise, pointer to a TYear will be returned. It won't be copied, so it MUST NOT be freed by the caller of this function.

log :

A KPTrainingLog

year :

Year in format yyyy

Returns :

Year-structure that represents a year.


kp_training_log_get_size ()

guint       kp_training_log_get_size        (KPTrainingLog *log);

Returns the number of entries in the log

log :

A KPTrainingLog

Returns :

Number of entries in the log.


kp_training_log_get_all_entries ()

GList*      kp_training_log_get_all_entries (KPTrainingLog *log);

log :

Returns :


kp_training_log_get_all_entries_between ()

GList*      kp_training_log_get_all_entries_between
                                            (KPTrainingLog *log,
                                             GDate *start,
                                             GDate *end,
                                             GList **sports);

log :

start :

end :

sports :

Returns :


kp_training_log_get_workout_params_between ()

gdouble**   kp_training_log_get_workout_params_between
                                            (KPTrainingLog *log,
                                             KPTrainingLogDataModemode,
                                             const gchar *sport,
                                             const gchar *param,
                                             GDate *start,
                                             GDate *end,
                                             guint *days_between);

Get the distance of every kp_workout between two dates and return data as dynamic two-dimensional array. It must be freed with kp_array_2d_free()-func.

If days_between is not NULL, number of days between two dates will be stored in it.

log :

A KPTrainingLog

Param2 :

sport :

Show only params when the sport of the workout is this, NULL = all

param :

The name of the param

start :

Starting date.

end :

Ending date.

days_between :

Number of days between start and end will be stored in days_between.

Returns :

Two-dimensional gdouble-array of data


kp_training_log_get_workout_params_year ()

gdouble**   kp_training_log_get_workout_params_year
                                            (KPTrainingLog *log,
                                             const gchar *param,
                                             guint year,
                                             guint *days_between);

log :

param :

year :

days_between :

Returns :

Two-dimensional gdouble-array of data


kp_training_log_get_day ()

GList*      kp_training_log_get_day         (KPTrainingLog *log,
                                             guint d,
                                             guint m,
                                             guint y);

Get list of all kp_workouts and other entries for any day in the log. As usual, if some error happens, NULL will be returned. Entries are not copied, so they MUST NOT be freed.

log :

A KPTrainingLog

d :

Day number

m :

Month number (1-12)

y :

Year number

Returns :

List of all the entries in a day.


kp_training_log_get_month ()

GList*      kp_training_log_get_month       (KPTrainingLog *log,
                                             gint year,
                                             gint month);

log :

year :

month :

Returns :


kp_training_log_is_modified ()

gboolean    kp_training_log_is_modified     (KPTrainingLog *log);

log :

Returns :


kp_training_log_get_month_as_chart_data ()

gdouble**   kp_training_log_get_month_as_chart_data
                                            (KPTrainingLog *log,
                                             guint year,
                                             guint month,
                                             guint month_len,
                                             const gchar *param);

log :

year :

month :

month_len :

param :

Returns :


kp_training_log_get_week_total ()

gdouble     kp_training_log_get_week_total  (KPTrainingLog *log,
                                             GDate *date,
                                             const gchar *param);

log :

date :

param :

Returns :


kp_training_log_get_param_day ()

gdouble     kp_training_log_get_param_day   (KPTrainingLog *log,
                                             GDate *date,
                                             const gchar *param);

Return a double value of sum of the entries' params in a day.

log :

A KPTrainingLog.

date :

The date of the day as GDate.

param :

Param of which value to get.

Returns :

a gdouble which can be zero if the requested param is invalid or if its value is zero or if some other error happens.


kp_training_log_foreach ()

void        kp_training_log_foreach         (KPTrainingLog *log,
                                             GFunc func,
                                             gpointer data);

Call some function for each entry in the log.

NOTE: This function can not be used to remove all the entries from the log, because kp_training_log_remove() may destroy some structures which are needed to iterate the log! So you must use kp_training_log_remove_all().

log :

A KPTrainingLog

func :

A func to execute

data :

Data to pass to the func


kp_training_log_get_data_as_tree_store ()

GtkTreeStore* kp_training_log_get_data_as_tree_store
                                            (KPTrainingLog *log);

log :

Returns :


kp_training_log_dump ()

void        kp_training_log_dump            (KPTrainingLog *log);

Dump the contents of the log to stdout. Could be used for debugging.

log :

A KPTrainingLog