diff --git a/doc/meson.build b/doc/meson.build index 422d0b8..5e8ca89 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -16,8 +16,9 @@ if docs_enabled output: 'valadoc', command: [ valadoc, docs_deps, - '--use-svg-images', '--doclet=html', + '--internal', + '--private', '--force', '--package-name=@0@'.format(meson.project_name()), '--package-version=@0@'.format(meson.project_version()), diff --git a/lib/db/arrienda.vala b/lib/db/arrienda.vala index ec1b264..c0d6875 100644 --- a/lib/db/arrienda.vala +++ b/lib/db/arrienda.vala @@ -17,12 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Arrienda class based on the database table + */ public class Arrienda : GLib.Object { + /** + * The price + */ public uint precio { get; set; default = 0; } + /** + * The date the vehicle needs to be returned + */ public string fecha_devolucion { get; set; default = ""; } + /** + * The vehicle + */ public Vehiculo vehiculo { get; set; default = null; } + /** + * The compnay + */ public Empresa empresa { get; set; default = null; } + /** + * Initialize the Arrienda class + * @param precio The price + * @param fecha_devolucion The date when the vehicle has to be returned + * @param vehiculo The Vehicle + * @param empresa The company + */ public Arrienda (uint precio = 0, string fecha_devolucion = "", Vehiculo? vehiculo = null, Empresa? empresa = null) { this.precio = precio; this.fecha_devolucion = fecha_devolucion; @@ -30,6 +52,11 @@ namespace LibSernatur { this.empresa = empresa; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Arrienda + */ public static Arrienda[]? get_all_arriendas(Database conn) { var res = conn.exec (" SELECT A.precio, A.fecha_devolucion, diff --git a/lib/db/asociado.vala b/lib/db/asociado.vala index a5cc33a..43dfd01 100644 --- a/lib/db/asociado.vala +++ b/lib/db/asociado.vala @@ -17,6 +17,9 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Asociado class based on the database table + */ public class Asociado : GLib.Object { public string fecha_llegada { get; set; default = ""; } public string hora_llegada { get; set; default = ""; } @@ -25,13 +28,29 @@ namespace LibSernatur { public Tour tour { get; set; default = null; } public Lugar lugar { get; set; default = null; } + /** + * Initialize the Asociado class + * @param fecha_llegada The date of arrival + * @param hora_llegada The time of arrival + * @param fecha_salida The date of departure + * @param hora_salida The time of departure + * @param tour The tour taken + * @param lugar The place visisted + */ public Asociado (string fecha_llegada = "", string hora_llegada = "", string fecha_salida = "", string hora_salida = "", Tour? tour = null, Lugar? lugar = null) { this.fecha_llegada = fecha_llegada; this.hora_llegada = hora_llegada; this.fecha_salida = fecha_salida; this.hora_salida = hora_salida; + this.tour = tour; + this.lugar = lugar; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Asociado + */ public static Asociado[]? get_all_asociados(Database conn) { var res = conn.exec (" SELECT A.fecha_llegada, A.hora_llegada, A.fecha_salida, A.hora_salida diff --git a/lib/db/categoria.vala b/lib/db/categoria.vala index 56e33ea..51918bf 100644 --- a/lib/db/categoria.vala +++ b/lib/db/categoria.vala @@ -17,15 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Categoria class based on the database table + */ public class Categoria : GLib.Object { + /** + * The id of the category + */ public uint id_categoria { get; set; default = 0; } + /** + * The description of the category + */ public string descripcion_categoria { get; set; default = ""; } + /** + * Initialize the Categoria class + * @param id_categoria The id of the category + * @param descripcion_categoria The description of the category + */ public Categoria (uint id_categoria = 0, string descripcion_categoria = "") { this.id_categoria = id_categoria; this.descripcion_categoria = descripcion_categoria; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Categoria + */ public static Categoria[]? get_all_categorias(Database conn) { var res = conn.exec (" SELECT id_categoria, descripcion_categoria FROM categoria diff --git a/lib/db/ciudad.vala b/lib/db/ciudad.vala index 4eb4657..7cf6a9d 100644 --- a/lib/db/ciudad.vala +++ b/lib/db/ciudad.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Ciudad class based on the database table + */ public class Ciudad : GLib.Object { + /** + * The id of the city + */ public uint id_ciudad { get; set; default = 0; } + /** + * The name of the city + */ public string nombre_ciudad { get; set; default = ""; } + /** + * The region + */ public Region region { get; set; default = null; } + /** + * Initialize the Ciudad class + * @param id_ciudad The id of the city + * @param nombre_ciudad The name of the city + * @param region The region + * */ public Ciudad (uint id_ciudad = 0, string nombre_ciudad = "", Region? region = null) { this.id_ciudad = id_ciudad; this.nombre_ciudad = nombre_ciudad; this.region = region; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Ciudad + */ public static Ciudad[]? get_all_ciudades(Database conn) { var res = conn.exec (" SELECT C.id_ciudad, C.nombre_ciudad, diff --git a/lib/db/contacto_emergencia.vala b/lib/db/contacto_emergencia.vala index de3b471..544a544 100644 --- a/lib/db/contacto_emergencia.vala +++ b/lib/db/contacto_emergencia.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The ContactoEmergencia class based on the database table + */ public class ContactoEmergencia : GLib.Object { + /** + * The id of the contact + */ public uint id_contacto { get; set; default = 0; } + /** + * The contact's phone number + */ public uint telefono_emergencia { get; set; default = 0; } + /** + * The contact's name + */ public string nombre_emergencia { get; set; default = ""; } + /** + * Initialize the ContactoEmergencia class + * @param id_contacto The id of the contact + * @param telefono_emergencia The contact's phone number + * @param nombre_emergencia The contact's name + */ public ContactoEmergencia (uint id_contacto = 0, uint telefono_emergencia = 0, string nombre_emergencia = "") { this.id_contacto = id_contacto; this.telefono_emergencia = telefono_emergencia; this.nombre_emergencia = nombre_emergencia; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of ContactoEmergencia + */ public static ContactoEmergencia[]? get_all_contactos(Database conn) { var res = conn.exec ("SELECT id_contacto, telefono_emergencia, nombre_emergencia FROM contacto_emergencia"); if (res.get_status () != ExecStatus.TUPLES_OK) { diff --git a/lib/db/descuento.vala b/lib/db/descuento.vala index 6f3520f..bcaf9eb 100644 --- a/lib/db/descuento.vala +++ b/lib/db/descuento.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Descuento class based on the database table + */ public class Descuento : GLib.Object { + /** + * The id of the discount + */ public uint id_descuento { get; set; default = 0; } + /** + * The description of the discount + */ public string descripcion_descuento { get; set; default = ""; } + /** + * The percentage of the discount + */ public float porcentaje { get; set; default = 0; } + /** + * Initialize the Descuento class + * @param id_descuento The id of the discount + * @param descripcion_descuento The description of the discount + * @param porcentaje The percentage of the discount + */ public Descuento (uint id_descuento = 0, string descripcion_descuento = "", float porcentaje = 0) { this.id_descuento = id_descuento; this.descripcion_descuento = descripcion_descuento; this.porcentaje = porcentaje; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Descuento + */ public static Descuento[]? get_all_descuentos(Database conn) { var res = conn.exec (" SELECT id_descuento, descripcion_descuento, porcentaje FROM descuento diff --git a/lib/db/empresa.vala b/lib/db/empresa.vala index 64e1349..e19faa4 100644 --- a/lib/db/empresa.vala +++ b/lib/db/empresa.vala @@ -17,12 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Empresa class based on the database table + */ public class Empresa : GLib.Object { + /** + * The RUT of the company + */ public string rut_empresa { get; set; default = ""; } + /** + * The name of the company + */ public string nombre_empresa { get; set; default = ""; } + /** + * The name of the contact in the company + */ public string contacto { get; set; default = ""; } + /** + * The phone number of the contact + */ public uint telefono { get; set; default = 0; } + /** + * Initialize the Empresa class + * @param rut_empresa The RUT of the company + * @param nombre_empresa The name of the company + * @param contacto The name of the contact in the company + * @param telefono The phone number of the contact + */ public Empresa (string rut_empresa = "", string nombre_empresa = "", string contacto = "", uint telefono = 0) { this.rut_empresa = rut_empresa; this.nombre_empresa = nombre_empresa; @@ -30,6 +52,11 @@ namespace LibSernatur { this.telefono = telefono; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Empresa + */ public static Empresa[]? get_all_empresas(Database conn) { var res = conn.exec (" SELECT rut_empresa, nombre_empresa, contacto, telefono FROM empresa diff --git a/lib/db/enfermedad.vala b/lib/db/enfermedad.vala index c012d64..c5c738b 100644 --- a/lib/db/enfermedad.vala +++ b/lib/db/enfermedad.vala @@ -17,15 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Enfermedad class based on the database table + */ public class Enfermedad : GLib.Object { + /** + * The id of the illness + */ public uint id_enfermedad { get; set; default = 0; } + /** + * The description of the illness + */ public string descripcion_enfermedad { get; set; default = ""; } + /** + * Initialize the Enfermedad class + * @param id_enfermedad The id of the illness + * @param descripcion_enfermedad The description of the illness + */ public Enfermedad (uint id_enfermedad = 0, string descripcion_enfermedad = "") { this.id_enfermedad = id_enfermedad; this.descripcion_enfermedad = descripcion_enfermedad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Enfermedad + */ public static Enfermedad[]? get_all_enfermedades(Database conn) { var res = conn.exec (" SELECT id_enfermedad, descripcion_enfermedad FROM enfermedad diff --git a/lib/db/especialidad.vala b/lib/db/especialidad.vala index fe71f1c..7773f89 100644 --- a/lib/db/especialidad.vala +++ b/lib/db/especialidad.vala @@ -17,15 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Esepcialidad class based on the database table + */ public class Especialidad : GLib.Object { + /** + * The id of the specialty + */ public uint id_especialidad { get; set; default = 0; } + /** + * The description of the specialty + */ public string descripcion_especialidad { get; set; default = ""; } + /** + * Initialize the Especialidad class + * @param id_especialidad The specialty id + * @param descripcion_especialidad The description of the specialty + */ public Especialidad (uint id_especialidad = 0, string descripcion_especialidad = "") { this.id_especialidad = id_especialidad; this.descripcion_especialidad = descripcion_especialidad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Especialidad + */ public static Especialidad[]? get_all_especialidades(Database conn) { var res = conn.exec (" SELECT id_especialidad, descripcion_especialidad FROM especialidad diff --git a/lib/db/guia.vala b/lib/db/guia.vala index b10890b..ef6cada 100644 --- a/lib/db/guia.vala +++ b/lib/db/guia.vala @@ -17,13 +17,39 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Guia class based on the database table + */ public class Guia : GLib.Object { + /** + * The RUT of the guide + */ public string rut_guia { get; set; default = ""; } + /** + * The name of the guide + **/ public string nombre_guia { get; set; default = ""; } + /** + * The stree name + */ public string calle { get; set; default = ""; } + /** + * The street number + */ public uint numero { get; set; default = 0; } + /** + * The city + */ public Ciudad ciudad { get; set; default = null; } + /** + * Initialize the Guia class + * @param rut_guia The RUT of the guide + * @param nombre_guia The name of the guide + * @param calle The street name + * @param numero The street number + * @param ciudad The city + */ public Guia (string rut_guia = "", string nombre_guia = "", string calle = "", uint numero = 0, Ciudad? ciudad = null) { this.rut_guia = rut_guia; this.nombre_guia = nombre_guia; @@ -32,6 +58,11 @@ namespace LibSernatur { this.ciudad = ciudad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Guia + */ public static Guia[]? get_all_guias(Database conn) { var res = conn.exec (" SELECT G.rut_guia, G.nombre_guia, G.calle, G.numero, diff --git a/lib/db/lugar.vala b/lib/db/lugar.vala index 96935fc..8098978 100644 --- a/lib/db/lugar.vala +++ b/lib/db/lugar.vala @@ -17,13 +17,39 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Lugar class based on the database table + */ public class Lugar : GLib.Object { + /** + * The id of the place + */ public uint id_lugar { get; set; default = 0; } + /** + * The name of the place + */ public string nombre_lugar { get; set; default = ""; } + /** + * The cost to enter + */ public uint valor_entrada { get; set; default = 0; } + /** + * The level of difficulty + */ public uint nivel { get; set; default = 0; } + /** + * The city + */ public Ciudad ciudad { get; set; default = null; } + /** + * Initialize the Lugar class + * @param id_lugar The id of the place + * @param nombre_lugar The name of the place + * @param valor_entrada The cost to enter + * @param nivel The level of difficulty + * @param ciudad The city + */ public Lugar (uint id_lugar = 0, string nombre_lugar = "", uint valor_entrada = 0, uint nivel = 0, Ciudad? ciudad = null) { this.id_lugar = id_lugar; this.nombre_lugar = nombre_lugar; @@ -32,6 +58,11 @@ namespace LibSernatur { this.ciudad = ciudad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Lugar + */ public static Lugar[]? get_all_lugares(Database conn) { var res = conn.exec (" SELECT L.id_lugar, L.nombre_lugar, L.valor_entrada, L.nivel, diff --git a/lib/db/participa.vala b/lib/db/participa.vala index eea21ae..0ef4c99 100644 --- a/lib/db/participa.vala +++ b/lib/db/participa.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Participa class based on the database table + */ public class Participa : GLib.Object { + /** + * The tour + */ public Tour tour { get; set; default = null; } + /** + * The guide + */ public Guia guia { get; set; default = null; } + /** + * The category + */ public Categoria categoria { get; set; default = null; } + /** + * Initialize the Participa class + * @param tour The tour + * @param guia The guide + * @param categoria The category + */ public Participa (Tour? tour = null, Guia? guia = null, Categoria? categoria = null) { this.tour = tour; this.guia = guia; this.categoria = categoria; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Participa + */ public static Participa[]? get_all_participas(Database conn) { var res = conn.exec (" SELECT T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas, diff --git a/lib/db/posee.vala b/lib/db/posee.vala index d1c6354..59e0e6f 100644 --- a/lib/db/posee.vala +++ b/lib/db/posee.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Posee class based on the database table + */ public class Posee : GLib.Object { + /** + * The specialty level + */ public uint nivel_especialidad { get; set; default = 0; } + /** + * The guide + */ public Guia guia { get; set; default = null; } + /** + * The speciality + */ public Especialidad especialidad { get; set; default = null; } + /** + * Initialize the Posee class + * @param nivel_especialidad The specialty level + * @param guia The guide + * @param especialidad The specialty + */ public Posee (uint nivel_especialidad = 0, Guia? guia = null, Especialidad? especialidad = null) { this.nivel_especialidad = nivel_especialidad; this.guia = guia; this.especialidad = especialidad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Posee + */ public static Posee[]? get_all_posees(Database conn) { var res = conn.exec (" SELECT P.nivel_especialidad, diff --git a/lib/db/realiza.vala b/lib/db/realiza.vala index d31e9c7..89c2ada 100644 --- a/lib/db/realiza.vala +++ b/lib/db/realiza.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Realiza class based on the database table + */ public class Realiza : GLib.Object { + /** + * The tour + */ public Tour tour { get; set; default = null; } + /** + * The tourist + */ public Turista turista { get; set; default = null; } + /** + * The discount + */ public Descuento descuento { get; set; default = null; } + /** + * Initialize the Realiza class + * @param tour The tour + * @param turista The tourist + * @param descuento The discount + */ public Realiza (Tour? tour = null, Turista? turista = null, Descuento? descuento = null) { this.tour = tour; this.turista = turista; this.descuento = descuento; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Realiza + */ public static Realiza[]? get_all_realizas(Database conn) { var res = conn.exec (" SELECT T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas, diff --git a/lib/db/region.vala b/lib/db/region.vala index ddac767..097e682 100644 --- a/lib/db/region.vala +++ b/lib/db/region.vala @@ -17,15 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Region class based on the database table + */ public class Region : GLib.Object { + /** + * The id of the region + */ public uint id_region { get; set; default = 0; } + /** + * The name of the region + */ public string nombre_region { get; set; default = ""; } + /** + * Initialize the Region class + * @param id_region The region id + * @param nombre_region The region name + */ public Region (uint id_region = 0, string nombre_region = "") { this.id_region = id_region; this.nombre_region = nombre_region; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Region + */ public static Region[]? get_all_regiones(Database conn) { var res = conn.exec (" SELECT id_region, nombre_region FROM region diff --git a/lib/db/requerir_auto.vala b/lib/db/requerir_auto.vala index 7ff06b3..c738681 100644 --- a/lib/db/requerir_auto.vala +++ b/lib/db/requerir_auto.vala @@ -17,17 +17,40 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The RequerirAuto class based on the database table + */ public class RequerirAuto : GLib.Object { + /** + * The chofer + */ public string chofer { get; set; default = ""; } + /** + * The tour + */ public Tour tour { get; set; default = null; } + /** + * The vehicle + */ public Vehiculo vehiculo { get; set; default = null; } + /** + * Initialize the RequerirAuto class + * @param chofer The chofer + * @param tour The tour + * @param vehiculo The vehicle + */ public RequerirAuto (string chofer = "", Tour? tour = null, Vehiculo? vehiculo = null) { this.chofer = chofer; this.tour = tour; this.vehiculo = vehiculo; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of RequerirAuto + */ public static RequerirAuto[]? get_all_requerir_autos(Database conn) { var res = conn.exec (" SELECT R.chofer, diff --git a/lib/db/tiene_enfermedad.vala b/lib/db/tiene_enfermedad.vala index 069c63b..42b5ea4 100644 --- a/lib/db/tiene_enfermedad.vala +++ b/lib/db/tiene_enfermedad.vala @@ -17,15 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The TieneEnfermedad class based on the database table + */ public class TieneEnfermedad : GLib.Object { + /** + * The tourist + */ public Turista turista { get; set; default = null; } + /** + * The illness + */ public Enfermedad enfermedad { get; set; default = null; } + /** + * Initialize the TieneEnfermedad class + * @param turista The tourist + * @param enfermedad The illness + */ public TieneEnfermedad (Turista? turista = null, Enfermedad? enfermedad = null) { this.turista = turista; this.enfermedad = enfermedad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of TieneEnfermedad + */ public static TieneEnfermedad[]? get_all_tiene_enfermedades(Database conn) { var res = conn.exec (" SELECT T.rut_turista, T.nombre_turista, T.fecha_nacimento, diff --git a/lib/db/tour.vala b/lib/db/tour.vala index a49cfe5..3d5444d 100644 --- a/lib/db/tour.vala +++ b/lib/db/tour.vala @@ -17,14 +17,44 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Tour class based on the database table + */ public class Tour : GLib.Object { + /** + * The tour id + */ public uint id_tour { get; set; default = 0; } + /** + * The tour name + */ public string nombre_tour { get; set; default = ""; } + /** + * The individual cost + */ public uint costo_indiv { get; set; default = 0; } + /** + * The group cost + */ public uint costo_grupal { get; set; default = 0; } + /** + * The minimum number of people + */ public uint minima_personas { get; set; default = 0; } + /** + * The city + */ public Ciudad ciudad { get; set; default = null; } + /** + * Initialize the Tour class + * @param id_tour The tour id + * @param nombre_tour The tour name + * @param costo_indiv The individual cost + * @param costo_grupal The group cost + * @param minima_personas The minimum number of people + * @param ciudad The city + */ public Tour (uint id_tour = 0, string nombre_tour = "", uint costo_indiv = 0, uint costo_grupal = 0, uint minima_personas = 0, Ciudad? ciudad = null) { this.id_tour = id_tour; this.nombre_tour = nombre_tour; @@ -34,6 +64,11 @@ namespace LibSernatur { this.ciudad = ciudad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Tour + */ public static Tour[]? get_all_tours(Database conn) { var res = conn.exec (" SELECT T.id_tour, T.nombre_tour, T.costo_indiv, T.costo_grupal, T.minima_personas, diff --git a/lib/db/turista.vala b/lib/db/turista.vala index b8c8022..86f032b 100644 --- a/lib/db/turista.vala +++ b/lib/db/turista.vala @@ -17,12 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Turista class based on the database table + */ public class Turista : GLib.Object { + /** + * The RUT of the tourist + */ public string rut_turista { get; set; default = ""; } + /** + * The tourist name + */ public string nombre_turista { get; set; default = ""; } + /** + * The birth date of the tourist + */ public string fecha_nacimento { get; set; default = ""; } + /** + * The emergency contact + */ public ContactoEmergencia contacto_emergencia { get; set; default = null; } + /** + * Initilize the Turista class + * @param rut_turista The RUT of the tourist + * @param nombre_turista The tourist name + * @param fecha_nacimento The birth date of the tourist + * @param contacto_emergencia The emergency contact + */ public Turista (string rut_turista = "", string nombre_turista = "", string fecha_nacimento = "", ContactoEmergencia? contacto_emergencia = null) { this.rut_turista = rut_turista; this.nombre_turista = nombre_turista; @@ -30,6 +52,12 @@ namespace LibSernatur { this.contacto_emergencia = contacto_emergencia; } + + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Turista + */ public static Turista[]? get_all_turistas(Database conn) { var res = conn.exec (" SELECT T.rut_turista, T.nombre_turista, T.fecha_nacimento, diff --git a/lib/db/vehiculo.vala b/lib/db/vehiculo.vala index 488756c..7da334a 100644 --- a/lib/db/vehiculo.vala +++ b/lib/db/vehiculo.vala @@ -17,12 +17,34 @@ namespace LibSernatur { using Postgres; using Wrapper; + /** + * The Vehiculo class based on the database table + */ public class Vehiculo : GLib.Object { + /** + * The license plate + */ public string patente { get; set; default = ""; } + /** + * The year of the vehicle + */ public uint ano_vehiculo { get; set; default = 0; } + /** + * The make of the vehicle + */ public string marca { get; set; default = ""; } + /** + * The capacity of the vehicle + */ public uint capacidad { get; set; default = 0; } + /** + * Initialize the Vehiculo class + * @param patente The license plate + * @param ano_vehiculo The year of the vehicle + * @param marca The make of the vehicle + * @param capacidad The capacity of the vehicle + */ public Vehiculo (string patente = "", uint ano_vehiculo = 0, string marca = "", uint capacidad = 0) { this.patente = patente; this.ano_vehiculo = ano_vehiculo; @@ -30,6 +52,11 @@ namespace LibSernatur { this.capacidad = capacidad; } + /** + * Get all tuples and fields from database + * @param conn The database connection to use + * @return Returns an array of Vehiculo + */ public static Vehiculo[]? get_all_vehiculos(Database conn) { var res = conn.exec (" SELECT patente, ano_vehiculo, marca, capacidad FROM vehiculo diff --git a/lib/dbwrapper.vala b/lib/dbwrapper.vala index 4683bb0..ce58c10 100644 --- a/lib/dbwrapper.vala +++ b/lib/dbwrapper.vala @@ -12,6 +12,9 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/** + * The main sernatur library namespace + */ namespace LibSernatur { /** * This is the database namespace for Sernatur @@ -23,49 +26,116 @@ namespace LibSernatur { namespace Wrapper { using Postgres; + /** + * The errors that can be thrown by fields in the database + */ public errordomain Field { NOTFOUND } + /** + * This is a wrapper for Postgresql results + */ public class ResultWrapper : GLib.Object { + /** + * The result that this is wrapped around + */ public unowned Result result { get; set; default = null; } + /** + * Initialize the result wrapper + * @param result The result to wrap around + */ public ResultWrapper (Result? result = null) { this.result = result; } + /** + * Return the string value based on tuple and field number + * @param tup_num The tuple number + * @param field_num The field number + * @return Returns a string of the value + */ public string get_string_v (int tup_num, int field_num) { return result.get_value (tup_num, field_num); } + /** + * Return the int value based on tuple and field number + * @param tup_num The tuple number + * @param field_num The field number + * @return Returns an int of the value + */ public int get_int_v (int tup_num, int field_num) { return int.parse (result.get_value (tup_num, field_num)); } + /** + * Return the float value based on tuple and field number + * @param tup_num The tuple number + * @param field_num The field number + * @return Returns a float of the value + */ public float get_float_v (int tup_num, int field_num) { return float.parse(result.get_value (tup_num, field_num)); } + /** + * Return the double value based on tuple and field number + * @param tup_num The tuple number + * @param field_num The field number + * @return Returns a double of the value + */ public double get_double_v (int tup_num, int field_num) { return double.parse (result.get_value (tup_num, field_num)); } + /** + * Return the string value based on tuple number and field name + * @param tup_num The tuple number + * @param name The field name + * @return Returns a string of the value + */ public string get_string_n (int tup_num, string name) throws Field { return get_string_v (tup_num, check_field_found (result.get_field_number (name), name)); } + /** + * Return the int value based on tuple number and field name + * @param tup_num The tuple number + * @param name The field name + * @return Returns an int of the value + */ public int get_int_n (int tup_num, string name) throws Field { return get_int_v (tup_num, check_field_found (result.get_field_number (name), name)); } + /** + * Return the float value based on tuple number and field name + * @param tup_num The tuple number + * @param name The field name + * @return Returns a float of the value + */ public float get_float_n (int tup_num, string name) throws Field { return get_float_v (tup_num, check_field_found (result.get_field_number (name), name)); } + /** + * Return the double value based on tuple number and field name + * @param tup_num The tuple number + * @param name The field name + * @return Returns a double of the value + */ public double get_double_n (int tup_num, string name) throws Field { return get_double_v (tup_num, check_field_found (result.get_field_number (name), name)); } + /** + * Check if the field is found in the results, if not throw a Field error + * @param field_num The field number to check for + * @param name The field name we were looking for + * @return The field number that corresponds to the field name + */ private int check_field_found (int field_num, string name) throws Field { if (field_num == -1) { throw new Field.NOTFOUND (dgettext (null, "The field %s was not found in the query results!"), name); diff --git a/lib/rut.vala b/lib/rut.vala index 085f5c4..e8d991e 100644 --- a/lib/rut.vala +++ b/lib/rut.vala @@ -15,26 +15,69 @@ namespace LibSernatur { namespace Person { + /** + * The errors that can be thrown by the Rut class + */ public errordomain InvalidRut { + /** + * The RUT is invalid + */ INVALID, + /** + * The RUT is too large, larger than 100.000.000 + */ TOOLARGE, + /** + * The verifier is incorrect + */ INVALIDVERIFIER } + /** + * This class handles parsing and validation of RUTs + */ public class Rut : GLib.Object { + /** + * The cleaned RUT + */ private string clean_rut; + /** + * The pretty RUT, e.g. with periods and dash + */ private string pretty_rut; + /** + * The verifier + */ private unichar verifier; + /** + * The type of identifier + */ public enum Type { + /** + * Company + */ RUN, + /** + * Person + */ RUT } + /** + * Initialize the Rut class + * @param rut The RUT to parse + * @throws InvalidRut Thrown if the RUT is invalid in any way + */ public Rut (string rut) throws InvalidRut { parse (rut); } + /** + * Parse the rut that was passed to the constructor + * @param rut The RUT to parse + * @throws InvalidRut Thrown if the RUT is invalid in any way + */ private void parse (string rut) throws InvalidRut { try { var regex = new Regex ("^[ ]*([0-9.]{0,11}[\\-]?[0-9kK])?[ ]*$"); @@ -73,6 +116,9 @@ namespace LibSernatur { } } + /** + * Add periods and dash to the RUT to make it look pretty + */ private void pretty () { string new_rut = ""; string temp_rut = this.clean_rut.reverse (); @@ -87,6 +133,11 @@ namespace LibSernatur { this.pretty_rut = new_rut + "-" + this.verifier.to_string (); } + /** + * Generate a verifier based off the RUT + * @param rut The RUT used to generate the verifier + * @return Returns the verifier + */ private unichar generate_verfifier (string rut) { /** * 1. Multiply each digit of the RUT by 2, 3, ..., 7, 2, 3, ... from the end of the RUT moving forward. @@ -130,14 +181,26 @@ namespace LibSernatur { } } + /** + * Get the clean RUT + * @return Returns the cleaned up RUT + */ public string get_clean_rut () { return this.clean_rut + this.verifier.to_string (); } + /** + * Get the RUT + * @return Returns the RUT with periods and dash + */ public string get_rut () { return this.pretty_rut; } + /** + * Check the type of identifier + * @return Returns the type of identifier, Type.RUT if it's a company or Type.RUN if it's a person + */ public Type type () { uint rut = int.parse (this.clean_rut); if (rut < 100000000 && rut > 50000000) { diff --git a/src/config.vala.in b/src/config.vala.in index 43434e6..e571e6a 100644 --- a/src/config.vala.in +++ b/src/config.vala.in @@ -14,7 +14,13 @@ namespace Sernatur { namespace Constants { + /** + * The package name used for translations + */ public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; + /** + * The version of the application + */ public const string VERSION = "@VERSION@"; } } diff --git a/src/main_window.vala b/src/main_window.vala index 3460ba7..8b8e9d7 100644 --- a/src/main_window.vala +++ b/src/main_window.vala @@ -12,9 +12,6 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * The main Sernatur namespace - */ namespace Sernatur { using LibSernatur.Person; using LibSernatur.DB; @@ -24,12 +21,24 @@ namespace Sernatur { */ [GtkTemplate (ui = "/cl/cromer/ubb/sernatur/main.window.ui")] public class MainWindow : Gtk.ApplicationWindow { + /** + * The opened database connection + */ private Postgres.Database conn; - + /** + * The content grid to fill + */ private Gtk.Grid content; + /** + * The mainbox of the window + */ [GtkChild] private Gtk.Box mainbox; + /** + * This is a callback for when the close button is pressed on the window + * @param widget The widget that called this GtkCallback + */ [GtkCallback] private void window_quit(Gtk.Widget widget) { application.quit (); @@ -75,6 +84,10 @@ namespace Sernatur { return false; } + /** + * This is a callback for when the tours option in the menu is clicked + * @param menu_item The menu item that was clicked + */ [GtkCallback] private void menu_tours(Gtk.MenuItem menu_item) { var tour_window = new TourWindow (application, conn); @@ -82,6 +95,10 @@ namespace Sernatur { tour_window.show_all (); } + /** + * This is a callback for when the quit option in the menu is clicked + * @param menu_item The menu item that was clicked + */ [GtkCallback] private void menu_quit(Gtk.MenuItem menu_item) { application.quit (); diff --git a/src/sernatur.vala b/src/sernatur.vala index 05468b4..0380b74 100644 --- a/src/sernatur.vala +++ b/src/sernatur.vala @@ -18,9 +18,13 @@ namespace Sernatur { using Constants; using Gtk; - + /** + * If version is passed as an option on the console line + */ private static bool version = false; - + /** + * The valid options that can be used on the console line + */ private const GLib.OptionEntry[] options = { { "version", 'v', 0, OptionArg.NONE, ref version, "Display version number", null }, { null } @@ -30,11 +34,6 @@ namespace Sernatur { * The application class */ public class Application : global::Gtk.Application { - /** - * The main application window - */ - private MainWindow window; - /** * Initialize the application */ @@ -46,7 +45,7 @@ namespace Sernatur { * Run when the application is activated */ public override void activate () { - window = new MainWindow (this); + var window = new MainWindow (this); var settings = new GLib.Settings ("cl.cromer.ubb.sernatur.window"); window.set_default_size (settings.get_int("width"), settings.get_int("height")); diff --git a/src/tour_window.vala b/src/tour_window.vala index f9502b2..631208b 100644 --- a/src/tour_window.vala +++ b/src/tour_window.vala @@ -12,9 +12,6 @@ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * The main Sernatur namespace - */ namespace Sernatur { using LibSernatur.Person; using LibSernatur.DB; @@ -24,24 +21,62 @@ namespace Sernatur { */ [GtkTemplate (ui = "/cl/cromer/ubb/sernatur/tour.window.ui")] public class TourWindow : Gtk.ApplicationWindow { + /** + * The open database connection + */ private unowned Postgres.Database conn; - + /** + * The columns of the tree view + */ private enum Columns { + /** + * The toggle + */ TOGGLE, + /** + * The tour name + */ TOUR_NAME, + /** + * The individual cost + */ INDIV_COST, + /** + * The group cost + */ GROUP_COST, + /** + * The minimum people + */ MINIMUM_PEOPLE, + /** + * The name of the city + */ CITY, + /** + * The name of the region + */ REGION, + /** + * The number of colums in this enum + */ N_COLUMNS } - + /** + * The list that stores the contents in the tree view + */ private Gtk.ListStore list_store; - + /** + * The tree view widget + */ [GtkChild] private Gtk.TreeView tour_tree; + /** + * This callback is called when the user clicks a radio button next to a row + * @param toggle The toggle clicked + * @param path The row clicked + */ [GtkCallback] private void toggled(Gtk.CellRendererToggle toggle, string path) { Gtk.TreeModelForeachFunc deselect_all = (model, path, iter) => { @@ -65,8 +100,9 @@ namespace Sernatur { } /** - * Initialize the main window class + * Initialize the tour window class * @param application The application used to make the GLib object + * @param conn The database connection to use */ public TourWindow (Gtk.Application application, Postgres.Database conn) { GLib.Object (application: application);