![]() |
![]() |
![]() |
Kipinä Internals Reference Manual | ![]() |
---|---|---|---|---|
enum KPTrainingLogError; enum KPTrainingLogDataMode; typedef KPTrainingLogYear; 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, GError **err); 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); void kp_training_log_remove_all (KPTrainingLog *log); GSList* kp_training_log_get_sports (KPTrainingLog *log); GSList* kp_training_log_get_info (KPTrainingLog *log); const gchar* kp_training_log_get_info_entry (KPTrainingLog *log, const gchar *field); void kp_training_log_add_info_entry (KPTrainingLog *log, const gchar *field, const gchar *data); KPCalendarEntry* kp_training_log_get_entry (KPTrainingLog *log, guint d, guint m, guint y, const gchar *mark); guint kp_training_log_get_n_years (KPTrainingLog *log); 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_name, 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); KPDate* kp_training_log_get_earliest_date (KPTrainingLog *log); KPDate* kp_training_log_get_latest_date (KPTrainingLog *log); 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); void kp_training_log_set_filename (KPTrainingLog *log, const gchar *file); const gchar* kp_training_log_get_filename (KPTrainingLog *log); gboolean kp_training_log_is_written_to_disk (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_param_day (KPTrainingLog *log, GDate *date, const gchar *param_name); void kp_training_log_foreach (KPTrainingLog *log, GFunc func, gpointer data); void kp_training_log_dump (KPTrainingLog *log);
typedef enum { KP_TRAINING_LOG_SAVE_HTML_ERROR, KP_TRAINING_LOG_SAVE_ERROR, KP_TRAINING_LOG_OPEN_ERROR, KP_TRAINING_LOG_INTERNAL_ERROR } KPTrainingLogError;
typedef enum { KP_TRAINING_LOG_DATA_SUM, KP_TRAINING_LOG_DATA_AVG, KP_TRAINING_LOG_DATA_MIN, KP_TRAINING_LOG_DATA_MAX } KPTrainingLogDataMode;
KPTrainingLog* kp_training_log_new (void);
Create a new instance of KPTrainingLog.
Returns : | A KPTrainingLog |
KPTrainingLog* kp_training_log_new_from_file (const gchar *file, GError **err);
file : |
|
err : |
|
Returns : |
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. |
gboolean kp_training_log_create_html_stats (KPTrainingLog *log, const gchar *output_dir, GError **error);
log : |
|
output_dir : |
|
error : |
|
Returns : |
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. |
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. |
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. |
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 |
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 |
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 |
void kp_training_log_remove_all (KPTrainingLog *log);
This function removes all the workouts from the log.
After running this function, log
will be still ready
to use, it just doesn't contain any workouts after that.
log : |
A KPTrainingLog |
GSList* kp_training_log_get_sports (KPTrainingLog *log);
Get list of all different sports that have entries in the log.
log : |
A KPTrainingLog |
Returns : | List that should NOT be freed. |
GSList* kp_training_log_get_info (KPTrainingLog *log);
Returns a string that is attached to field field
.
log : |
A KPTrainingLog |
Returns : | A string that MUST NOT BE MODIFIED OR FREED! |
const gchar* kp_training_log_get_info_entry (KPTrainingLog *log, const gchar *field);
log : |
|
field : |
|
Returns : |
void kp_training_log_add_info_entry (KPTrainingLog *log, const gchar *field, const gchar *data);
Adds the information to the list of info entries. The data will be saved to the disk next time the log is saved.
log : |
A KPTrainingLog |
field : |
The field name |
data : |
The data to attach |
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. |
guint kp_training_log_get_n_years (KPTrainingLog *log);
log : |
|
Returns : |
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. |
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. |
GList* kp_training_log_get_all_entries (KPTrainingLog *log);
log : |
|
Returns : |
GList* kp_training_log_get_all_entries_between (KPTrainingLog *log, GDate *start, GDate *end, GList **sports);
log : |
|
start : |
|
end : |
|
sports : |
|
Returns : |
gdouble** kp_training_log_get_workout_params_between (KPTrainingLog *log, KPTrainingLogDataModemode, const gchar *sport, const gchar *param_name, 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_name : |
|
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 |
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 |
KPDate* kp_training_log_get_earliest_date (KPTrainingLog *log);
Get the date of the earliest workout or other entry that is in the log.
log : |
A KPTrainingLog |
Returns : | A newly-allocated KPDate-structure that must be freed. |
KPDate* kp_training_log_get_latest_date (KPTrainingLog *log);
Get the date of the latest workout or other entry that is in the log.
log : |
A KPTrainingLog |
Returns : | A newly-allocated KPDate-structure that must be freed. |
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. |
GList* kp_training_log_get_month (KPTrainingLog *log, gint year, gint month);
log : |
|
year : |
|
month : |
|
Returns : |
gboolean kp_training_log_is_modified (KPTrainingLog *log);
log : |
|
Returns : |
void kp_training_log_set_filename (KPTrainingLog *log, const gchar *file);
Set the filename that the log will be saved when requested.
log : |
A KPTrainingLog |
file : |
The filename |
const gchar* kp_training_log_get_filename (KPTrainingLog *log);
Get filename that training log lives or is to be saved.
log : |
A KPTrainingLog |
Returns : | const string that is owned by log or NULL if the log is unnamed. |
gboolean kp_training_log_is_written_to_disk (KPTrainingLog *log);
This function checks if this log is loaded from a file or it has been saved to the disk while running the program. This is mainly intented for use by save routines.
log : |
A KPTrainingLog |
Returns : | TRUE if the log is loaded from the file or has been already saved to the file. |
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 : |
gdouble kp_training_log_get_param_day (KPTrainingLog *log, GDate *date, const gchar *param_name);
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_name : |
|
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. |
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
|