Recuperado bin, lib e includes, sorry
parent
e890924e95
commit
b63b2ad256
|
|
@ -35,10 +35,4 @@ Olivia/[Dd]ebug*/
|
|||
OliviaTasks/x64/
|
||||
OliviaTasks/[Rr]elease*/
|
||||
OliviaTasks/[Dd]ebug*/
|
||||
lib/
|
||||
bin/
|
||||
bin/x64/debug
|
||||
bin/x64/release
|
||||
lib
|
||||
bin
|
||||
includes
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
#ifndef CLIC_EXPORT
|
||||
#ifdef _WINDLL
|
||||
#define CLIC_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define CLIC_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "LicUtilesDef.h"
|
||||
#include "ClientLicDef.h"
|
||||
#include "FileTransferDef.h"
|
||||
|
||||
|
||||
class FileTransferClient;
|
||||
class CLIC_EXPORT ClienteLicencias: public LicClientEscucha, public FileTransferClientLisener
|
||||
{
|
||||
CDialog *dprog;
|
||||
double porcen;
|
||||
public:
|
||||
FileTransferClient *ft;
|
||||
int dias_pregun;
|
||||
bool cancelaDescarga;
|
||||
bool espera_dlg;
|
||||
char dirTemp[256];//directorio temporal para dejar el instalador
|
||||
char dirLic[256];//path para guardar la licencia y la ultima vez que se pregunto si descargar lic
|
||||
|
||||
ClienteLicencias(void);
|
||||
~ClienteLicencias(void);
|
||||
|
||||
bool cargaLicencia();
|
||||
|
||||
virtual bool getClave(char* clave, char* producto );
|
||||
|
||||
virtual void muestaError( char* info, char* producto );
|
||||
|
||||
virtual bool descargaInstalador( Licencia *lic );
|
||||
|
||||
void descargaVersion( Licencia *lic);
|
||||
|
||||
virtual void setStatus( double porcent );
|
||||
|
||||
virtual void finTransfer( bool finalFeliz );
|
||||
|
||||
virtual bool getPathLic( char* path, char* producto );
|
||||
|
||||
virtual bool cancelTransfer();
|
||||
|
||||
private:
|
||||
bool preguntarDescarga();
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef FT_EXPORT
|
||||
#ifdef _WINDLL
|
||||
#define FT_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define FT_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
struct Usuario_conx_0;
|
||||
class FT_EXPORT IDataUserProvider
|
||||
{
|
||||
public:
|
||||
virtual bool fill(Usuario_conx_0 *user, char *pathRaid) = 0;
|
||||
virtual bool getConf(char *ip, int *port) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#define FILE_TRANSMISION_GET_FILES 7
|
||||
#define FILE_TRANSMISION_GET_DIRS 8
|
||||
|
||||
class FT_EXPORT FileTransferClientLisener
|
||||
{
|
||||
public:
|
||||
virtual void setStatus(double porcent){};
|
||||
virtual void finTransfer(bool finalFeliz){};
|
||||
virtual bool cancelTransfer(){ return false;};
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#ifndef LICUTL_EXPORT
|
||||
#ifdef _WINDLL
|
||||
#define LICUTL_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LICUTL_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define VERSION_LICENCIA 100
|
||||
|
||||
#define LU_LICENCIA_CADUCA 1 //licencia normal
|
||||
#define LU_LICENCIA_PROPIETARIA 2 //licencia propietaria, por defecto da licencia
|
||||
|
||||
|
||||
#define LU_DEFAULT_FILE "data.lic"
|
||||
#define LU_DEFAULT_SERVER "desa.narvaling.com"
|
||||
//#define LU_DEFAULT_SERVER "192.168.1.60"
|
||||
|
||||
#define LU_DEFAULT_PUERTO 8051
|
||||
|
||||
class Licencia;
|
||||
//structuras
|
||||
class LICUTL_EXPORT DBLicProvider
|
||||
{
|
||||
public:
|
||||
virtual bool fill( Licencia* lic )=0;//rellena datos licencia
|
||||
virtual int licCount( Licencia* lic )=0;//cuenta numero de licencias
|
||||
virtual bool fillInstal( Licencia* lic )=0;//rellena instalador
|
||||
virtual bool setAcceso( Licencia* lic, __int64 *ultAcc, __int64 *actualAcceso)=0;
|
||||
virtual bool getConf( char *ip, int *port )=0;//configuracion de escucha
|
||||
};
|
||||
|
||||
class LICUTL_EXPORT LicClientEscucha
|
||||
{
|
||||
public:
|
||||
virtual bool getClave(char* clave, char* producto )=0;//pide clave (pidiendosela al usuario)
|
||||
virtual bool getServer( char*server, int *puerto, char* producto){ server[0]=0;*puerto=0;return false;}//pide servidor de licencias (no obligada)
|
||||
virtual bool getPathLic( char* path, char* producto ){path[0]=0; return true;}//pide path de archivo de licencia (no obligada)
|
||||
virtual void muestaError(char* info, char* producto){}
|
||||
virtual bool descargaInstalador(Licencia *lic){return true;}//true si revisamos instalador, false si no
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,591 @@
|
|||
/**
|
||||
* @file GeneralDef.cs
|
||||
* Clase con definiciones globales comunes al proyecto Olivia y a OliviaTasks.
|
||||
*/
|
||||
/**
|
||||
* Clase con definiciones globales comunes al proyecto Olivia y a OliviaTasks.
|
||||
*/
|
||||
namespace OliviaDef
|
||||
{
|
||||
public static class GeneralDef
|
||||
{
|
||||
//*************************************************************************************
|
||||
//Enums y structs generales
|
||||
/**
|
||||
* Tipos de ejecución de la herramienta Olivia
|
||||
*/
|
||||
public enum TiposOliv
|
||||
{
|
||||
OlivNoDef = -1,
|
||||
OlivLimp, //<Indica herramienta de limpieza viaria
|
||||
OlivResi, //<Indica herramienta de recogida de residuos
|
||||
OlivJard, //<Indica herramienta de jardines
|
||||
OlivEstReg, //<Indica herramienta de estacionamiento regulado
|
||||
OlivN //<Número herramientas
|
||||
};
|
||||
/**
|
||||
* Unidades del tiempo de tratamiento
|
||||
*/
|
||||
public enum OlvTiposTto
|
||||
{
|
||||
OlvTipTtoNoDef = -1,
|
||||
OlvTipTtoMin,
|
||||
OlvTipTtoMh,
|
||||
OlvTipTtoMh_eje,
|
||||
OlvTipTtoM2h,
|
||||
OlvTipTtoM2h_eje,
|
||||
};
|
||||
//*************************************************************************************
|
||||
//Variables generales
|
||||
/*
|
||||
* Define el nombre en registro de la clave
|
||||
*/
|
||||
public const string OlvRegKey = "SOFTWARE\\Intergeo Tecnología\\Olivia";
|
||||
/*
|
||||
* Define el máximo y paso de la ventana de progreso de ejecución, el mínimo es 0
|
||||
*/
|
||||
public const int ProgrMax = 100;
|
||||
public const int ProgrStep = 5;
|
||||
public const int ParamN = 5;
|
||||
public const int ParamLimpN = 37;
|
||||
public const int ParamRecoN = 40;
|
||||
/*
|
||||
* Define el separador entre parámetros de la llamada al proceso oliviatasks
|
||||
*/
|
||||
public const string EjecGeoParamSep = "/";
|
||||
public const string EjecGeoProgName = "olivia";
|
||||
public const string EjecGeoParamIgual = ":";
|
||||
public const string NombOlvTasks = "OliviaTasks";
|
||||
public const string NombColSector = "SECTOR";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades generales
|
||||
*/
|
||||
public const string GrupoGen = "PATHS";
|
||||
/**
|
||||
* Define el nombre del grupo de GDBs (tanto para la gdb de datos generales como para la red navegable)
|
||||
*/
|
||||
public const string GrupoGDB = "GENERAL";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de capas generales
|
||||
*/
|
||||
public const string GrupoCapa = "CAPAS_GENERALES";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de limpieza
|
||||
*/
|
||||
public const string GrupoCapaLImp = "CAPAS_LIMP";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de limpieza
|
||||
*/
|
||||
public const string GrupoCampoLimp = "CAMPOS_LIMP";
|
||||
/**
|
||||
* Define el nombre del grupo de atributos de limpieza
|
||||
*/
|
||||
public const string GrupoAtribLimp = "ATRIBUTOS_LIMP";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de recogida
|
||||
*/
|
||||
public const string GrupoFiltLimp = "FILTROS_LIMP";
|
||||
/**
|
||||
* Define el nombre del grupo de parámetros de limpieza
|
||||
*/
|
||||
public const string GrupoParamLimp = "PARAM_LIMP";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de recogida
|
||||
*/
|
||||
public const string GrupoCampoReco = "CAMPOS_RECO";
|
||||
/**
|
||||
* Define el nombre del grupo de atributos de recogida
|
||||
*/
|
||||
public const string GrupoAtribReco = "ATRIBUTOS_RECO";
|
||||
/**
|
||||
* Define el nombre del grupo de atributos de la lateralidad de la carga de los vehículos
|
||||
*/
|
||||
public const string GrupoCampoLater = "ATRIBUTOS_LATERAL";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de recogida
|
||||
*/
|
||||
public const string GrupoCampoSens = "CAMPOS_SENS";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de CSV
|
||||
*/
|
||||
public const string GrupoCampoCsv = "CAMPOS_CSV";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades de recogida
|
||||
*/
|
||||
public const string GrupoFiltReco = "FILTROS_RECO";
|
||||
/**
|
||||
* Define el nombre del grupo de parámetros de recogida
|
||||
*/
|
||||
public const string GrupoParamReco = "PARAM_RECO";
|
||||
/**
|
||||
* Define el nombre del grupo de parámetros de recogida
|
||||
*/
|
||||
public const string GrupoSimbVsm = "SIMBOL_VSM";
|
||||
/**
|
||||
* Define el nombre del grupo de campos de la red navegable
|
||||
*/
|
||||
public const string GrupoCampoNW = "CAMPOS_NW";
|
||||
public const string GrupoCampoOtros = "OTROS_PARAM";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades generales
|
||||
*/
|
||||
public const string OliviaDirWork = "%dir_work%";
|
||||
/**
|
||||
* Define las propiedades generales a guardar y leer
|
||||
*/
|
||||
public const string GG_pw = "path_work";
|
||||
public const string GG_pg = "path_exe";
|
||||
public const string GG_pdl = "path_dll";
|
||||
public const string GG_pt = "path_temp";
|
||||
public const string GG_pd = "path_data";
|
||||
public const string GG_pn = "path_nw";
|
||||
public const string GG_pcar = "path_cart";
|
||||
public const string GG_pcfg = "path_cfgeo";
|
||||
public const string GG_strtto = "str_tto";
|
||||
////
|
||||
public const string GG_tipo = "tipo";
|
||||
public const string GG_ip = "ip";
|
||||
public const string GG_port = "port";
|
||||
public const string GG_tout = "tout";
|
||||
/////
|
||||
public const string GG_tco = "t_conv";
|
||||
public const string GG_tdc = "t_descan";
|
||||
public const string GG_npt = "n_ptsctrl";
|
||||
public const string GG_sec = "n_secdef";
|
||||
public const string GG_coox = "coor_inst_x";
|
||||
public const string GG_cooy = "coor_inst_y";
|
||||
public const string GG_hini = "h_inicio";
|
||||
public const string GG_trafic = "trafico";
|
||||
public const string GG_ais = "aislados";
|
||||
|
||||
/**
|
||||
* Define las propiedades de limpieza a enviar a oliviatasks
|
||||
*/
|
||||
public const string GL_res = "restr_cir";
|
||||
public const string GL_tto = "t_tto";
|
||||
public const string GL_uto = "u_tto";
|
||||
public const string GL_vdp = "v_despl";
|
||||
public const string GL_tdp = "t_despl";
|
||||
public const string GL_tca = "t_carg";
|
||||
public const string GL_anc = "anch_med";
|
||||
/**
|
||||
* Define las propiedades de recogida a enviar a oliviatasks
|
||||
*/
|
||||
public const string GR_camp_cap = "campo_capaci";
|
||||
public const string GR_kgM = "kg_max";
|
||||
public const string GR_camp_uds = "campo_uds";
|
||||
public const string GR_camp_kgrec = "campo_kgrecog";
|
||||
public const string GR_kgrecog = "recogida_kg";
|
||||
public const string GR_carga_cont = "carga_cont";
|
||||
public const string GR_dens = "densidad";
|
||||
public const string GR_tvc = "t_vacia";
|
||||
public const string GR_tdca = "t_descarg";
|
||||
public const string GR_tsal = "t_sallleg";
|
||||
public const string GR_anc = "anch_vehi";
|
||||
public const string GR_gir = "giro_vehi";
|
||||
public const string GR_descx = "coor_desc_x";
|
||||
public const string GR_descy = "coor_desc_y";
|
||||
public const string GR_sens_id = "sens_id";
|
||||
public const string GR_sens_url = "sens_url";
|
||||
public const string GR_sens_llen = "sens_lleno";
|
||||
public const string GR_sens_fecha = "sens_fechai";
|
||||
public const string GR_sens_fechaf = "sens_fechaf";
|
||||
public const string GR_sens_modo = "md_pet";
|
||||
public const string GR_lateral = "lateralidad";
|
||||
/**
|
||||
* Define las GDBs a leer
|
||||
*/
|
||||
public const string GDB_gen = "gdb_general";
|
||||
public const string GDB_nw = "red_carreteras";
|
||||
public const string simb_vsm = "simbologia_vsm";
|
||||
public const string simb_esri = "simbologia_esri";
|
||||
public const string GDB_puerto = "puerto";
|
||||
public const string GG_buff = "buffer_export";
|
||||
/**
|
||||
* Define los nombres de las capas de la GDB general
|
||||
*/
|
||||
public const string GC_eje = "eje_via";
|
||||
public const string GC_zon = "zonas";
|
||||
public const string GC_rest = "restricciones";
|
||||
public const string GC_muni = "municipios";
|
||||
/**
|
||||
* Define los nombres de los campos a consultar en la GDB general
|
||||
*/
|
||||
public const string GA_zon = "cons_zon";
|
||||
public const string GA_cap_zon = "cons_cap_zon";
|
||||
/**
|
||||
* Define los nombres de las capas de limpieza de la GDB general
|
||||
*/
|
||||
public const string GCA_eje = "eje_via";
|
||||
public const string GCA_niv = "niveles";
|
||||
public const string GCA_zon = "zonas";
|
||||
public const string GCA_cont = "contenedor";
|
||||
public const string GCA_mobi = "mobiliario";
|
||||
public const string GCA_limp = "limp_meca";
|
||||
public const string GCA_inst = "instalaciones";
|
||||
public const string GCA_rest = "restricciones";
|
||||
public const string GCA_muni = "municipios";
|
||||
/**
|
||||
* Define los nombres de los campos de limpieza a consultar en la GDB general
|
||||
*/
|
||||
public const string GAA_entid = "cons_tip_ent";
|
||||
public const string GAA_mecan = "cons_mecaniz";
|
||||
public const string GAA_obser = "cons_obser";
|
||||
public const string GAA_anch_tip = "cons_anch_tip";
|
||||
public const string GAA_tipolo = "cons_tipolo";
|
||||
/**
|
||||
* Define los nombres de los atributos de limpieza a consultar en la GDB general
|
||||
*/
|
||||
public const string GAL_esc = "atr_esca";
|
||||
public const string GAL_fuent = "atr_fuent";
|
||||
public const string GAL_infan = "atr_infan";
|
||||
public const string GAL_pape = "atr_pape";
|
||||
public const string GAL_paso_niv = "atr_paso_niv";
|
||||
public const string GAL_pipi = "atr_pipi";
|
||||
public const string GAL_sane = "atr_sane";
|
||||
public const string GAL_acera = "atr_acera";
|
||||
public const string GAL_aparc = "atr_aparc";
|
||||
public const string GAL_bord = "atr_bord";
|
||||
public const string GAL_hoja = "atr_hoja";
|
||||
public const string GAL_peat = "atr_peat";
|
||||
public const string GAL_terri = "atr_terri";
|
||||
public const string GAL_ocio = "atr_ocio";
|
||||
public const string GAL_org_ofi = "atr_org_ofi";
|
||||
public const string GAL_parq = "atr_parq";
|
||||
public const string GAL_park = "atr_park";
|
||||
public const string GAL_play = "atr_play";
|
||||
public const string GAL_polid = "atr_polid";
|
||||
public const string GAL_turis = "atr_turis";
|
||||
public const string GAL_solar = "atr_solar";
|
||||
public const string GAL_suelo = "atr_suelo";
|
||||
public const string GAL_ap_lin = "atr_ap_lin";
|
||||
public const string GAL_ap_bat = "atr_ap_bat";
|
||||
/**
|
||||
* Define los nombres de los filtros de las consultas de limpieza a la GDB general
|
||||
*/
|
||||
public const string GFA_eje = "ejes";
|
||||
public const string GFA_blm = "bord_libre_mec";
|
||||
public const string GFA_blnm = "bord_libre_no_mec";
|
||||
public const string GFA_ba = "bord_aparc";
|
||||
public const string GFA_bam = "bord_acera_mec";
|
||||
public const string GFA_banm = "bord_acera_no_mec";
|
||||
public const string GFA_cpm = "calle_peat_mec";
|
||||
public const string GFA_cpnm = "calle_peat_no_mec";
|
||||
public const string GFA_chm = "caida_hoja_mec";
|
||||
public const string GFA_chnm = "caida_hoja_no_mec";
|
||||
public const string GFA_cont = "contenedores";
|
||||
public const string GFA_pap = "pape";
|
||||
public const string GFA_inf = "zon_inf";
|
||||
public const string GFA_pipi = "pipican";
|
||||
public const string GFA_sane = "sanecan";
|
||||
/**
|
||||
* Define los nombres de los parámetros de limpieza a la GDB general
|
||||
*/
|
||||
public const string GPA_ttoM = "t_tratamiento_max";
|
||||
public const string GPA_ttom = "t_tratamiento_min";
|
||||
public const string GPA_v_despM = "v_desplaz_max";
|
||||
public const string GPA_v_despm = "v_desplaz_min";
|
||||
public const string GPA_cardescM = "t_carga_desc_max";
|
||||
public const string GPA_cardescm = "t_carga_desc_min";
|
||||
public const string GPA_cardesc = "t_carga_desc";
|
||||
public const string GPA_t_despM = "t_desplaz_max";
|
||||
public const string GPA_t_despm = "t_desplaz_min";
|
||||
public const string GPA_t_desp = "t_desplaz";
|
||||
public const string GPA_convM = "t_convenio_max";
|
||||
public const string GPA_convm = "t_convenio_min";
|
||||
public const string GPA_conv = "t_convenio";
|
||||
public const string GPA_descM = "t_descanso_max";
|
||||
public const string GPA_descm = "t_descanso_min";
|
||||
public const string GPA_desc = "t_descanso";
|
||||
public const string GPA_h_inicio = "hora_inicio";
|
||||
public const string GPA_anchM = "ancho_via_max";
|
||||
public const string GPA_anchm = "ancho_via_min";
|
||||
public const string GPA_anch = "ancho_via";
|
||||
public const string GPA_ttoBarMan = "t_tratamiento_BarMan";
|
||||
public const string GPA_ttoBarManMant = "t_tratamiento_BarManMant";
|
||||
public const string GPA_ttoBarMMot = "t_tratamiento_BarMMot";
|
||||
public const string GPA_ttoBarMC = "t_tratamiento_BarMC";
|
||||
public const string GPA_ttoBarMAP = "t_tratamiento_BarMAP";
|
||||
public const string GPA_ttoBarMix = "t_tratamiento_BarMix";
|
||||
public const string GPA_ttoBalMan = "t_tratamiento_BalMan";
|
||||
public const string GPA_ttoBalMC = "t_tratamiento_BalMC";
|
||||
public const string GPA_ttoBalMAP = "t_tratamiento_BalMAP";
|
||||
public const string GPA_ttoBalMix = "t_tratamiento_BalMix";
|
||||
public const string GPA_ttoBL = "t_tratamiento_BL";
|
||||
public const string GPA_ttoCH = "t_tratamiento_CH";
|
||||
public const string GPA_ttoVPap = "t_tratamiento_VPap";
|
||||
public const string GPA_ttoLPap = "t_tratamiento_LPap";
|
||||
public const string GPA_ttoLC = "t_tratamiento_LC";
|
||||
public const string GPA_ttoLZI = "t_tratamiento_LZI";
|
||||
public const string GPA_ttoLPip = "t_tratamiento_LPip";
|
||||
public const string GPA_ttoLS = "t_tratamiento_LS";
|
||||
public const string GPA_vdespBarMan = "v_desp_BarMan";
|
||||
public const string GPA_vdespBarManMant = "v_desp_BarManMant";
|
||||
public const string GPA_vdespBarMMot = "v_desp_BarMMot";
|
||||
public const string GPA_vdespBarMC = "v_desp_BarMC";
|
||||
public const string GPA_vdespBarMAP = "v_desp_BarMAP";
|
||||
public const string GPA_vdespBarMix = "v_desp_BarMix";
|
||||
public const string GPA_vdespBalMan = "v_desp_BalMan";
|
||||
public const string GPA_vdespBalMC = "v_desp_BalMC";
|
||||
public const string GPA_vdespBalMAP = "v_desp_BalMAP";
|
||||
public const string GPA_vdespBalMix = "v_desp_BalMix";
|
||||
public const string GPA_vdespBL = "v_desp_BL";
|
||||
public const string GPA_vdespCH = "v_desp_CH";
|
||||
public const string GPA_vdespVPap = "v_desp_VPap";
|
||||
public const string GPA_vdespLPap = "v_desp_LPap";
|
||||
public const string GPA_vdespLC = "v_desp_LC";
|
||||
public const string GPA_vdespLZI = "v_desp_LZI";
|
||||
public const string GPA_vdespLPip = "v_desp_LPip";
|
||||
public const string GPA_vdespLS = "v_desp_LS";
|
||||
public const string GPA_umbral_reco = "umbral_recogida";
|
||||
/**
|
||||
* Define los nombres de las capas de recogida de la GDB general
|
||||
*/
|
||||
public const string GCR_cont = "conte";
|
||||
public const string GCR_inst = "instala";
|
||||
public const string GCR_desc = "descarg";
|
||||
/**
|
||||
* Define los nombres de los campos de recogida a leer en la GDB general
|
||||
*/
|
||||
public const string GAT_organica = "organica";
|
||||
public const string GAT_resto = "resto";
|
||||
public const string GAT_envase = "envase";
|
||||
public const string GAT_papel = "papel";
|
||||
public const string GAT_vidrio = "vidrio";
|
||||
public const string GAT_trasera = "trasera";
|
||||
public const string GAT_lateral = "lateral";
|
||||
public const string GAT_superior = "superior";
|
||||
public const string GAT_bilat = "bilat";
|
||||
public const string GAT_bolseo = "bolseo";
|
||||
public const string GAT_lavado = "lavado";
|
||||
/**
|
||||
* Define los nombres de los atributos de recogida a leer en la GDB general
|
||||
*/
|
||||
public const string GAR_id = "id";
|
||||
public const string GAR_nomrec = "nomrec";
|
||||
public const string GAR_lateral = "lateralidad";
|
||||
public const string GAR_frac = "frac";
|
||||
public const string GAR_capac = "capac";
|
||||
public const string GAR_uds = "uds";
|
||||
public const string GAR_kgrec = "kgrec";
|
||||
public const string GAR_kgrec_val = "kgrec_val";
|
||||
public const string GAR_is_lleno = "is_lleno";
|
||||
public const string GAR_is_campo = "is_campo";
|
||||
/**
|
||||
* Define los nombres de los atributos de la lateralidad de la carga de los vehículos de recogida de residuos.
|
||||
*/
|
||||
public const string GAL_amb = "ambos";
|
||||
public const string GAL_dcha = "derecha";
|
||||
public const string GAL_izq = "izquierda";
|
||||
/**
|
||||
* Define los nombres de los campos de la capa de sensores a leer en los datos de entrada
|
||||
*/
|
||||
public const string GSR_id = "id";
|
||||
public const string GSR_url = "url";
|
||||
public const string GSR_fecha = "fecha";
|
||||
public const string GSR_hora = "hora";
|
||||
public const string GSR_fechaf = "fecha_fin";
|
||||
public const string GSR_horaf = "hora_fin";
|
||||
/**
|
||||
* Define los nombres de los campos de los datos externos (CSV) a leer en los datos de entrada
|
||||
*/
|
||||
public const string GCR_id = "id";
|
||||
public const string GCR_llen = "llenado";
|
||||
public const string GCR_fecha = "fecha";
|
||||
/**
|
||||
* Define los nombres de los filtros de las consultas a la GDB general para la RECOGIDA
|
||||
*/
|
||||
public const string GFR_org = "organica";
|
||||
public const string GFR_rest = "resto";
|
||||
public const string GFR_env = "envases";
|
||||
public const string GFR_pap = "papel";
|
||||
public const string GFR_vid = "vidrio";
|
||||
public const string GFR_otr = "otra";
|
||||
public const string GFR_tra = "trasera";
|
||||
public const string GFR_lat = "lateral";
|
||||
public const string GFR_sup = "superior";
|
||||
public const string GFR_bi = "bilateral";
|
||||
public const string GFR_bol = "bolseo";
|
||||
public const string GFR_lav = "lavadp";
|
||||
public const string GFR_otra = "otra";
|
||||
/**
|
||||
* Define los nombres de los parámetros de recogida a la GDB general
|
||||
*/
|
||||
public const string GPR_vaciM = "t_vaciado_max";
|
||||
public const string GPR_vacim = "t_vaciado_min";
|
||||
public const string GPR_llegsalM = "t_llega_sale_max";
|
||||
public const string GPR_llegsalm = "t_llega_sale_min";
|
||||
public const string GPR_llegsal = "t_llega_sale";
|
||||
public const string GPR_descM = "t_descarga_max";
|
||||
public const string GPR_descm = "t_descarga_min";
|
||||
public const string GPR_desc = "t_descarga";
|
||||
public const string GPR_convM = "t_convenio_max";
|
||||
public const string GPR_convm = "t_convenio_min";
|
||||
public const string GPR_conv = "t_convenio";
|
||||
public const string GPR_descansoM = "t_descanso_max";
|
||||
public const string GPR_descansom = "t_descanso_min";
|
||||
public const string GPR_descanso = "t_descanso";
|
||||
public const string GPR_h_inicio = "hora_inicio";
|
||||
public const string GPR_dv_org = "dens_vehi_org";
|
||||
public const string GPR_dv_res = "dens_vehi_res";
|
||||
public const string GPR_dv_env = "dens_vehi_env";
|
||||
public const string GPR_dv_pap = "dens_vehi_pap";
|
||||
public const string GPR_dv_vid = "dens_vehi_vid";
|
||||
public const string GPR_dv_otr = "dens_vehi_otr";
|
||||
public const string GPR_dc_org = "dens_cont_org";
|
||||
public const string GPR_dc_res = "dens_cont_res";
|
||||
public const string GPR_dc_env = "dens_cont_env";
|
||||
public const string GPR_dc_pap = "dens_cont_pap";
|
||||
public const string GPR_dc_vid = "dens_cont_vid";
|
||||
public const string GPR_dc_otr = "dens_cont_otr";
|
||||
public const string GPR_anchv_3 = "anch_vehi_3";
|
||||
public const string GPR_anchv_2 = "anch_vehi_2";
|
||||
public const string GPR_anchv_s = "anch_vehi_s";
|
||||
public const string GPR_rgiro_3 = "radio_giro_3";
|
||||
public const string GPR_rgiro_2 = "radio_giro_2";
|
||||
public const string GPR_rgiro_s = "radio_giro_s";
|
||||
public const string GPR_tv_tra = "t_vaci_trasera";
|
||||
public const string GPR_tv_lat = "t_vaci_lateral";
|
||||
public const string GPR_tv_sup = "t_vaci_superior";
|
||||
public const string GPR_tv_bi = "t_vaci_bilateral";
|
||||
public const string GPR_tv_bol = "t_vaci_bolseo";
|
||||
public const string GPR_tv_lav = "t_vaci_lavado";
|
||||
public const string GPR_tv_otr = "t_vaci_otra";
|
||||
public const string GPR_kgmaxM = "kgmax_max";
|
||||
public const string GPR_kgmaxm = "kgmax_min";
|
||||
public const string GPR_carga_maxM = "carga_max_max";
|
||||
public const string GPR_carga_maxm = "carga_max_min";
|
||||
/**
|
||||
* Define los nombres de los símbolos que hay en la galería de VSM
|
||||
*/
|
||||
public const string GSV_auto = "auto";
|
||||
public const string GSV_bil = "bilat";
|
||||
public const string GSV_bol = "bolseo";
|
||||
public const string GSV_abi = "caja";
|
||||
public const string GSV_neu = "neumatic";
|
||||
public const string GSV_pil = "pilas";
|
||||
public const string GSV_lenv = "lat_env";
|
||||
public const string GSV_lpap = "lat_pap";
|
||||
public const string GSV_lvid = "lat_vid";
|
||||
public const string GSV_lorg = "lat_orga";
|
||||
public const string GSV_lrest = "lat_rest";
|
||||
public const string GSV_tenv = "tra_env";
|
||||
public const string GSV_tpap = "tra_pa";
|
||||
public const string GSV_tvid = "tra_vid";
|
||||
public const string GSV_torg = "tra_org";
|
||||
public const string GSV_trest = "tra_rest";
|
||||
public const string GSV_ienv = "iglu_env";
|
||||
public const string GSV_ipap = "iglu_pap";
|
||||
public const string GSV_ivid = "igul_vid";
|
||||
public const string GSV_sot = "soterrad";
|
||||
public const string GSV_esc = "ecalera";
|
||||
public const string GSV_fuen = "fuent";
|
||||
public const string GSV_jinf = "zon_inf";
|
||||
public const string GSV_pap = "papelera";
|
||||
public const string GSV_pniv = "paso_niv";
|
||||
public const string GSV_pip = "pippican";
|
||||
public const string GSV_san = "sanecan";
|
||||
public const string GSV_ace = "acera";
|
||||
public const string GSV_apar = "aparcamient";
|
||||
public const string GSV_bor = "bordillo";
|
||||
public const string GSV_hoj = "caida_hoja";
|
||||
public const string GSV_pea = "peatonal";
|
||||
public const string GSV_terr = "terriza";
|
||||
public const string GSV_oci = "ocio";
|
||||
public const string GSV_ofi = "organism_ofici";
|
||||
public const string GSV_par = "parque";
|
||||
public const string GSV_park = "parking";
|
||||
public const string GSV_pla = "playa";
|
||||
public const string GSV_pol = "polidep";
|
||||
public const string GSV_tur = "turistico";
|
||||
public const string GSV_sol = "solar";
|
||||
public const string GSV_sue = "uso_suelo";
|
||||
/**
|
||||
* Define los nombres de los campos de la red navegable que tiene que leer
|
||||
*/
|
||||
public const string GTC_onew = "cons_onew";
|
||||
public const string GTC_kph = "cons_kph";
|
||||
public const string GTC_fow = "cons_fow";
|
||||
public const string GTC_name = "cons_name";
|
||||
/**
|
||||
* Define los nombres de los atributos de la red navegable que tiene que leer
|
||||
*/
|
||||
public const string GTA_TF = "atr_TF";
|
||||
public const string GTA_FT = "atr_FT";
|
||||
public const string GTA_N = "atr_N";
|
||||
public const string GTA_pedes = "atr_pedes";
|
||||
|
||||
/**
|
||||
* Nombre de los campos que lee en limpieza
|
||||
*/
|
||||
public const string GTO_girmax ="Giro_max_vehiculo";
|
||||
public const string GTO_anch_peat ="Ancho_peat_def";
|
||||
public const string GTO_anch_ace = "Ancho_acera_def";
|
||||
public const string GTO_anch_aplin = "Ancho_ap_lin_def";
|
||||
public const string GTO_anch_apbat = "Ancho_ap_bat_def";
|
||||
public const string GTO_anch_bordlib = "Ancho_bord_lib_def";
|
||||
public const string GTO_desv_max = "Desv_max";
|
||||
public const string GTO_desv_max_abs = "Desv_max_abs";
|
||||
/**
|
||||
* Define el nombre para mandar a oliviatasks la configuración
|
||||
*/
|
||||
public const string SockConf = "CONFIG";
|
||||
/**
|
||||
* Define el nombre para responder oliviatasks que ok la configuración
|
||||
*/
|
||||
public const string SockConfOk = "CONFIG_OK";
|
||||
/**
|
||||
* Define el nombre para responder oliviatasks que nok la configuración
|
||||
*/
|
||||
public const string SockConfNOk = "CONFIG_NOK";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks el progreso
|
||||
*/
|
||||
public const string SockProgr = "PROGRESO";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks la tarea
|
||||
*/
|
||||
public const string SockTarea = "TAREA";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks que cancele
|
||||
*/
|
||||
public const string SockCanc = "CANCELA";
|
||||
/**
|
||||
* Define el nombre para responder el oliviatasks a que cancele
|
||||
*/
|
||||
public const string SockCancOk = "CANCELA_OK";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks los sectores, una vez se han calculado
|
||||
*/
|
||||
public const string SockSect = "SECTORES";
|
||||
/**
|
||||
* Define el nombre para pedir avisar oliviatasks de que ha finalizado la sectorización
|
||||
*/
|
||||
public const string SockSectFin = "SECTORES_FIN";
|
||||
/**
|
||||
* Define el nombre para pedir avisar oliviatasks de que ha finalizado la sectorización
|
||||
*/
|
||||
public const string SockFinOk = "FIN_OK";
|
||||
/**
|
||||
* Define el nombre para pedir avisar oliviatasks de que ha finalizado la sectorización
|
||||
*/
|
||||
public const string SockFinNOk = "FIN_NOK";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks los sectores, una vez se han calculado
|
||||
*/
|
||||
public const string SockPlanFin = "PLANIF_FIN";
|
||||
/**
|
||||
* Define el nombre para pedir a oliviatasks los sectores, una vez se han calculado
|
||||
*/
|
||||
public const string SockPlan = "PLANIF";
|
||||
/**
|
||||
* Define el nombre para mandar a oliviatasks la configuración para planificación, ya se ha hecho sectorización
|
||||
*/
|
||||
public const string SockConfPlan = "CONFIG_PLANIF";
|
||||
/**
|
||||
* Define el nombre para mandar a oliviatasks la configuración para planificación, ya se ha hecho sectorización
|
||||
*/
|
||||
public const string SockConfTodo = "CONFIG_TODO";
|
||||
//*************************************************************************************
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
#pragma once
|
||||
#ifndef CartoBase_h
|
||||
#define CartoBase_h
|
||||
|
||||
#include "base_head.h"
|
||||
#include "CartoBaseDef.h"
|
||||
#include "CartoBaseElements.h"
|
||||
#include "CartoElements.h"
|
||||
#include "IaDataTable.h"
|
||||
#include <map>
|
||||
/*
|
||||
hacer el memoryclear
|
||||
guardar dbf ia
|
||||
*/
|
||||
class Cb_file;
|
||||
class UTILES_EXPORT CartoBase: public SetEntities, public SetPtsR, public DataIaCartoBase
|
||||
{
|
||||
//clases amigo-----------------
|
||||
friend class CartoBaseInfoEntity;
|
||||
friend class CartoBaseInfoPto;
|
||||
friend class CartoBaseInfoLine;
|
||||
friend class CartoBaseInfoBuilder;
|
||||
friend class CartoPto;
|
||||
friend class CartoLine;
|
||||
private:
|
||||
//info interna-------------------------------
|
||||
int ref;//referencia para el siguiente elemento
|
||||
CartoBasePaintedProps _defaultpaintedProps;
|
||||
CartoBaseColor _defaultColor;
|
||||
//array de informacion de entidades
|
||||
Cgarray<CartoBaseEntity> _entities;//entidades
|
||||
Cgarray<CartoBasePoint> _points;//coordenadas
|
||||
Cgarray<CartoBaseLine> _lines;//lineas
|
||||
Cgarray<CartoBasePaintedProps> _paintedProps;//propiedades de pintado
|
||||
Cgarray<CartoBaseColor> _colors;
|
||||
std::map<int, int> refIndex;//indexado por referencias;
|
||||
//datos de ia-----------------------------------------
|
||||
char iaName[12];//nombre columna ia tipo IntIa
|
||||
int typeIA;//indica el tipo de informacion asociada que se utilizara
|
||||
public:
|
||||
|
||||
IaDataTable dataIa;
|
||||
DataIaCartoBase *iaEx;
|
||||
enum TypedataIa
|
||||
{
|
||||
NIa=0,//sin informacion asociada
|
||||
IntIa,//usa solo un entero por entidad como ia con nombre de columna iaName
|
||||
DtIa,//usa la dataIa para almacenar info asociada
|
||||
ExIa//informacion asociada externa
|
||||
};
|
||||
|
||||
CartoBase(void);
|
||||
~CartoBase(void);
|
||||
|
||||
//funciones-----------------------------------------------------------------
|
||||
CartoBaseInfoEntity get(int i);//acceso a entidad iesima (modo lectura)
|
||||
CartoBaseInfoEntity getRef(int r);//acceso a entidad con referencia r (modo lectura)
|
||||
|
||||
|
||||
//añade elementos
|
||||
bool add(CartoEntity& element);
|
||||
bool add(CartoBase& cad);
|
||||
|
||||
bool remove(int i);//pone marca de flag de borrado (pero sigue siendo accesible)
|
||||
bool removeRef(int r);
|
||||
|
||||
bool FastClear();//solo borra entidades y rehace las referencias
|
||||
bool clear();//limpia elementos borrados y ajusta memoria
|
||||
bool MemClear();//limpia memoria de todos los arrays
|
||||
|
||||
EntitiesArray* filter(EntitiesArray* dst, FilterEntities *filter);
|
||||
|
||||
virtual bool leer(char *path);
|
||||
virtual bool grabar(char *path);
|
||||
virtual bool leer(Cb_file *f);
|
||||
virtual bool grabar(Cb_file *f);
|
||||
|
||||
int addDefaultPaintedProps();//crea unas propiedades de pintado como las por defecto
|
||||
|
||||
bool importShp(char* path);//importa shp
|
||||
bool exportShp(char* path);//exporta a shp (todos los tipos que cuinciden con la primera)
|
||||
bool ptosExportShp(char* path);
|
||||
bool linesExportShp(char* path);
|
||||
|
||||
void del();//limpia toda la carto (sin liberar memoria)
|
||||
|
||||
//funciones de ia-------------------------------------------------------------------
|
||||
void* getIa(int refEnt);//devuelve informacion asociada externa de la entidad refEnt
|
||||
int getTypeIA(){return typeIA;}//devuelve el tipo de ia que tiene actualmente
|
||||
void setExIa(DataIaCartoBase* ia);//setea un ia externo
|
||||
int getEntityRef(int ientity);//devuelve la referencia
|
||||
void setNameIa(char *name);//pone el nombre de la col
|
||||
|
||||
//funciones por ser SetEntities
|
||||
virtual CartoBaseInfoEntity getEntity(int i);
|
||||
virtual int getNumberEntities();
|
||||
//funciones por ser SetPts
|
||||
virtual double* getPto(int i);
|
||||
virtual int getNumberPtos();
|
||||
//funciones auxiliares------------
|
||||
int getNexRef(){return ref;};
|
||||
|
||||
//funciones DataIaCartoBase
|
||||
virtual bool IaGetSize( int *ncolm );
|
||||
virtual bool IaGetColm( int icol, char* name, BYTE *type, int *size, int*ndecimal );
|
||||
virtual bool IaGetVal( int refEnt, int icol, int* v );
|
||||
virtual bool IaFinW(){return true;}
|
||||
|
||||
private:
|
||||
|
||||
int add(CartoBaseEntity* src);
|
||||
int add(CartoBasePoint* src);
|
||||
int add(CartoBaseLine* src);
|
||||
int add(CartoBasePaintedProps* src);
|
||||
int add(CartoBaseColor* src);
|
||||
|
||||
bool fexportShp(char* path, int type = CartoBaseTypes::Ndef);
|
||||
|
||||
void indexRef(bool buscaRepes=false);//indexa referencias
|
||||
void iniIndexRef();//crea indexado
|
||||
void reIndexRef();
|
||||
};
|
||||
|
||||
class FiterCartoBase: public SetEntities
|
||||
{
|
||||
public:
|
||||
CartoBase* cb;
|
||||
Cgarray<int> ind;
|
||||
|
||||
virtual CartoBaseInfoEntity getEntity( int i );
|
||||
|
||||
virtual int getNumberEntities();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "Fdbf.h"
|
||||
#include "CartoBase.h"
|
||||
|
||||
//clase helper para imporacion de un dbf a informacion asociada de cartobase
|
||||
class UTILES_EXPORT CartoBaseDBFManager: public ListenerDbf_W, public ListenerDbf_R
|
||||
{
|
||||
CartoBase *cb;
|
||||
int _oldRef;
|
||||
int _icol;
|
||||
int _nncol;
|
||||
int _nnrow;
|
||||
CartoBaseInfoEntity e;
|
||||
int rowE;
|
||||
SetEntities *setEnt;
|
||||
DataIaCartoBase* ia;
|
||||
public:
|
||||
|
||||
CartoBaseDBFManager(void);
|
||||
~CartoBaseDBFManager(void);
|
||||
virtual bool leer(char *path, CartoBase*cartb);
|
||||
virtual bool grabar(char *path, DataIaCartoBase* iawx, SetEntities* s);
|
||||
|
||||
|
||||
//funciones auxiliares-----------------------------------
|
||||
//funciones de lectura de shp--------------------------
|
||||
virtual bool DbfSet( int nrow, int ncolm );
|
||||
virtual bool DbfSetColm( char* name, BYTE type, int size );
|
||||
virtual bool DbfaddVal( int icol, int v );
|
||||
virtual bool DbfaddVal( int icol, double v );
|
||||
virtual bool DbfaddVal( int icol, __int64 v );
|
||||
virtual bool DbfaddVal( int icol, char* v );
|
||||
virtual bool DbfaddVal( int icol, void* v );
|
||||
virtual bool DbfFinRow();
|
||||
virtual bool DbfFinR();
|
||||
|
||||
//funciones de escritura de dbf-----------------------
|
||||
virtual bool DbfGet( int *nrow, int *ncolm);
|
||||
virtual bool DbfGetColm( int icol, char* name, BYTE *type, int *size, int*ndecimal );
|
||||
virtual bool DbfGetVal( int irow, int icol, int* v );
|
||||
virtual bool DbfGetVal( int irow, int icol, double* v );
|
||||
virtual bool DbfGetVal( int irow, int icol, __int64* v );
|
||||
virtual bool DbfGetVal( int irow, int icol, char** v );
|
||||
virtual bool DbfGetVal( int irow, int icol, void** v );
|
||||
virtual bool DbfFinW();
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
#ifndef CartoBaseDef_H
|
||||
#define CartoBaseDef_H
|
||||
#include "base_head.h"
|
||||
|
||||
namespace CartoBaseTypes{
|
||||
enum {
|
||||
Ndef = 0,
|
||||
Point,
|
||||
Line
|
||||
};
|
||||
};
|
||||
|
||||
//calse coleccion de puntos (double[3]) solo lectura
|
||||
class UTILES_EXPORT SetPtsR
|
||||
{
|
||||
public:
|
||||
virtual double* getPto(int i)=0;//devuelve el punto iesimo
|
||||
virtual int getNumberPtos()=0;//devuelve numero de puntos totales
|
||||
};
|
||||
//coleccion de puntos al que se le puede añadir mas
|
||||
class UTILES_EXPORT SetPtsW
|
||||
{
|
||||
public:
|
||||
virtual bool addPto(double* p)=0;//añade el punto p al conjunto
|
||||
};
|
||||
//constructor de setPtsW
|
||||
class UTILES_EXPORT SetPtsWBuilder
|
||||
{
|
||||
public:
|
||||
virtual SetPtsW *build()=0;//devuelve una nueva clase SetPtsW
|
||||
};
|
||||
class CartoBase;
|
||||
//interface de ia
|
||||
class UTILES_EXPORT DataIaCartoBase
|
||||
{
|
||||
public:
|
||||
virtual void* IaGet(int refEnt){return NULL;}
|
||||
|
||||
virtual void CBSet(CartoBase* cb){}
|
||||
virtual void IaRemove(int refEnt){}
|
||||
virtual void IaRemoveAll(){}
|
||||
virtual void IaAdd(int refEnt){}
|
||||
|
||||
//informa del numero de filas y columnas que tiene la ia
|
||||
virtual bool IaSet(int nrow, int ncolm){return true;}
|
||||
virtual bool IaSetColm(int icol, char* name, BYTE type, int size){return true;}
|
||||
virtual bool IaAddVal(int refEnt, int icol, int v){return true;}
|
||||
virtual bool IaAddVal(int refEnt, int icol, double v){return true;}
|
||||
virtual bool IaAddVal(int refEnt, int icol, __int64 v){return true;}
|
||||
virtual bool IaAddVal(int refEnt, int icol, char* v){return true;}
|
||||
virtual bool IaAddVal(int refEnt, int icol, void* v){return true;}
|
||||
virtual bool IaFinRow(int refEnt){return true;}
|
||||
virtual bool IaFinR(){return true;}
|
||||
|
||||
|
||||
virtual bool IaGetSize( int *ncolm ){return false;}
|
||||
virtual bool IaGetColm( int icol, char* name, BYTE *type, int *size, int*ndecimal ){return false;}
|
||||
virtual bool IaGetVal( int refEnt, int icol, int* v ){return false;}
|
||||
virtual bool IaGetVal( int refEnt, int icol, double* v ){return false;}
|
||||
virtual bool IaGetVal( int refEnt, int icol, __int64* v ){return false;}
|
||||
virtual bool IaGetVal( int refEnt, int icol, char** v ){return false;}
|
||||
virtual bool IaGetVal( int refEnt, int icol, void** v ){return false;}
|
||||
virtual bool IaFinW(){return true;}
|
||||
};
|
||||
|
||||
#define TYPE_FILE "CartoBase"
|
||||
#define VERSION_CART_BASE 100
|
||||
//falgs de entidades--------------
|
||||
#define CARTOBASE_DELETED_ENTITY 0x01
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "cartoBaseDef.h"
|
||||
#include "garray.h"
|
||||
#ifndef CartoBaseElements_H
|
||||
#define CartoBaseElements_H
|
||||
class CartoEntity;
|
||||
//clases internas de cartobase----------------------------------------------
|
||||
class UTILES_EXPORT CartoBaseEntity
|
||||
{
|
||||
public:
|
||||
int id; //indice a objeto
|
||||
int type; //tipo de entidad
|
||||
int idPaintp; //inide a propiedades
|
||||
int flagsUser; //flags para uso de usuario
|
||||
int flagsInt; //flags para uso interno
|
||||
int ref; //referencia unica por elemento
|
||||
|
||||
//tamaño---------
|
||||
int mima[2]; //indice a punto maximo y minimo (el elemento esta contenido entre dichos puntos)
|
||||
int ia; //indice a informacion adicional
|
||||
|
||||
CartoBaseEntity()
|
||||
{
|
||||
id = -1;
|
||||
idPaintp = -1;
|
||||
flagsInt = 0;
|
||||
}
|
||||
};
|
||||
//entidad interna de putno
|
||||
class UTILES_EXPORT CartoBasePoint
|
||||
{
|
||||
public:
|
||||
double pts[3];//coordenadas del punto
|
||||
|
||||
CartoBasePoint(){
|
||||
pts[0]=pts[1]=pts[2]=0;
|
||||
}
|
||||
};
|
||||
|
||||
//entidad interna de linea
|
||||
class UTILES_EXPORT CartoBaseLine
|
||||
{
|
||||
public:
|
||||
int ini; //inidce a punto inicio
|
||||
int n; //numero de puntos del lineal
|
||||
CartoBaseLine()
|
||||
{
|
||||
n = 0;
|
||||
ini = -1;
|
||||
}
|
||||
};
|
||||
//entidad interna de propiedades de pintado
|
||||
class UTILES_EXPORT CartoBasePaintedProps
|
||||
{
|
||||
public:
|
||||
int color; //indice a color
|
||||
int peso; //grosor o tamaño de letra (segun entidad)
|
||||
int prioridad; //prioridad de pintado
|
||||
int flags; //flags internos 0x1 (visto para los clear)
|
||||
CartoBasePaintedProps()
|
||||
{
|
||||
color = -1;
|
||||
peso = 1;
|
||||
flags = 0;
|
||||
}
|
||||
};
|
||||
//entidad interna de color
|
||||
class UTILES_EXPORT CartoBaseColor
|
||||
{
|
||||
public:
|
||||
|
||||
int color;
|
||||
int flags; //flags internos 0x1 (visto para los clear)
|
||||
CartoBaseColor()
|
||||
{
|
||||
color = 0;
|
||||
flags = 0;
|
||||
}
|
||||
};
|
||||
|
||||
//entidad base de informacion
|
||||
class CartoBase;
|
||||
class UTILES_EXPORT CartoBaseInfoEntity: public SetPtsR
|
||||
{
|
||||
public:
|
||||
//funciones externas
|
||||
CartoBasePoint* (*fpto)(CartoBaseInfoEntity *c);
|
||||
CartoBaseLine* (*fline)(CartoBaseInfoEntity *c);
|
||||
int i_entity;
|
||||
|
||||
CartoBase* ptr;
|
||||
|
||||
CartoBaseInfoEntity();
|
||||
|
||||
virtual bool isValid(); //dice si es valido o no la entidad de informacion
|
||||
virtual CartoBaseInfoEntity next(); //devuelve entidad siguiente
|
||||
virtual CartoBaseInfoEntity prev(); //devuelve entidad anterior
|
||||
|
||||
//acceso a informacion interna
|
||||
virtual CartoBasePoint* pto();
|
||||
virtual CartoBaseEntity* entity();
|
||||
virtual CartoBaseLine* line();
|
||||
virtual CartoBasePaintedProps* paintp();
|
||||
virtual CartoBaseColor* color();
|
||||
virtual CartoEntity* getCopy(CartoEntity *buf=NULL);
|
||||
//funciones SetPts--------------------------
|
||||
virtual double* getPto(int i);
|
||||
virtual int getNumberPtos();
|
||||
|
||||
void* getIa();
|
||||
double getLong();
|
||||
double disMedLines(SetPtsR *line2, double l_avan, double *desv=NULL);
|
||||
double disMedLines(SetPtsR *line2, double *desv=NULL);
|
||||
double DisPtoLine(double*p, int* idpto=NULL, double *lamb=NULL);
|
||||
SetPtsW *GetNPrimePtos(SetPtsW *ldst, int nptos, double dis, BOOL avanza);
|
||||
bool DivLine(SetPtsW* ldst1, SetPtsW* ldst2, int ip, double lamb);
|
||||
double *GetPtoDis(double dis, double *dst, double *distTot);
|
||||
double *PtInLine(int ip, double lamb, double *pp);
|
||||
double DplineSeg(double* s1, double *s2,int *n=NULL, double *lamd1=NULL,double *lamb2=NULL);
|
||||
};
|
||||
//calse coleccion de entidades
|
||||
class UTILES_EXPORT SetEntities
|
||||
{
|
||||
public:
|
||||
virtual CartoBaseInfoEntity getEntity(int i)=0;
|
||||
virtual int getNumberEntities()=0;
|
||||
};
|
||||
|
||||
//clase de filtrado de entidades
|
||||
class UTILES_EXPORT FilterEntities
|
||||
{
|
||||
public:
|
||||
virtual bool IsSeletedEntity(CartoBaseInfoEntity *e)=0;
|
||||
};
|
||||
|
||||
//array de entidades
|
||||
class UTILES_EXPORT EntitiesArray: public Cgarray<CartoBaseInfoEntity>, public SetEntities, public SetPtsR
|
||||
{
|
||||
public:
|
||||
virtual CartoBaseInfoEntity getEntity(int i);
|
||||
virtual int getNumberEntities();
|
||||
|
||||
virtual double* getPto(int i);
|
||||
virtual int getNumberPtos();
|
||||
|
||||
EntitiesArray* filter(EntitiesArray* dst, FilterEntities* filter);
|
||||
bool exportShp(char* path, int type = CartoBaseTypes::Ndef);
|
||||
};
|
||||
//entidad de informacion punto
|
||||
class UTILES_EXPORT CartoBaseInfoPto
|
||||
{
|
||||
public:
|
||||
static CartoBasePoint* pto(CartoBaseInfoEntity*c);
|
||||
};
|
||||
//entidad de informacion linea
|
||||
class UTILES_EXPORT CartoBaseInfoLine
|
||||
{
|
||||
public:
|
||||
|
||||
static CartoBasePoint* pto(CartoBaseInfoEntity*c);
|
||||
static CartoBaseLine* line(CartoBaseInfoEntity*c);
|
||||
};
|
||||
|
||||
//clase constructor de entidades info
|
||||
class UTILES_EXPORT CartoBaseInfoBuilder
|
||||
{
|
||||
public:
|
||||
static CartoBaseInfoEntity get(int i, CartoBase* ptr);
|
||||
static CartoEntity* get(int type);
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "garray.h"
|
||||
#include "CartoBase.h"
|
||||
|
||||
class Cb_file;
|
||||
class Fshape;
|
||||
//clase helper para inportacion de shp a un carto base
|
||||
class UTILES_EXPORT CartoBaseShpManager
|
||||
{
|
||||
CartoBase* cad;
|
||||
bool ImportPoints(Fshape *shp);
|
||||
bool Importline(Fshape *shp);
|
||||
bool ImportPoligon(Fshape *shp);
|
||||
bool ExportLine(Cb_file *file, Cb_file *fshx, SetEntities *entities);
|
||||
bool ExportPts(Cb_file *file, Cb_file *fshx, SetEntities *entities);
|
||||
|
||||
public:
|
||||
CartoBaseShpManager(void);
|
||||
~CartoBaseShpManager(void);
|
||||
|
||||
void set(CartoBase* cb){cad = cb;}
|
||||
|
||||
bool ImportShp(Cb_file *file);
|
||||
|
||||
bool ExportShp(Cb_file *file,Cb_file *fshx, SetEntities *entities, int type = CartoBaseTypes::Ndef);
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
#pragma once
|
||||
|
||||
#include "base_head.h"
|
||||
#include "CartoBaseDef.h"
|
||||
|
||||
class CartoBaseEntity;
|
||||
class CartoBasePaintedProps;
|
||||
class CartoBaseColor;
|
||||
//clases de elmentos de cartobase
|
||||
class UTILES_EXPORT CartoEntity : public SetPtsR
|
||||
{
|
||||
public:
|
||||
virtual int getType()//devuelve tipo de entidad
|
||||
{
|
||||
return CartoBaseTypes::Ndef;
|
||||
};
|
||||
|
||||
virtual int getnLines()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual CartoEntity* set(CartoBaseInfoEntity *src)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int CopyInTo(CartoBase *src)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
virtual double* getPto(int i){return 0;}
|
||||
|
||||
virtual int getNumberPtos(){return 0;}
|
||||
virtual double disMedLines(SetPtsR *line2, double *desv=NULL);
|
||||
|
||||
};
|
||||
|
||||
class UTILES_EXPORT CartoComun: public CartoEntity
|
||||
{
|
||||
public:
|
||||
int flagsUser;
|
||||
int color;
|
||||
int peso;
|
||||
int id;//ide de entidad
|
||||
int ia;
|
||||
int idPropsP;//ide de propiedades de pintado al que se va a poner
|
||||
|
||||
CartoComun()
|
||||
{
|
||||
flagsUser =0;
|
||||
color = 0;
|
||||
peso = 0;
|
||||
id = -1;
|
||||
ia=0;
|
||||
idPropsP = -1;
|
||||
}
|
||||
|
||||
//auxiliary funcition
|
||||
bool setInfo(CartoBaseInfoEntity * info);
|
||||
|
||||
CartoBaseEntity* get(CartoBaseEntity * dst);
|
||||
CartoBasePaintedProps* get(CartoBasePaintedProps * dst);
|
||||
CartoBaseColor* get(CartoBaseColor * dst);
|
||||
|
||||
|
||||
};
|
||||
|
||||
class UTILES_EXPORT CartoPto: public CartoComun
|
||||
{
|
||||
public:
|
||||
|
||||
double pt[3];
|
||||
CartoPto(){};
|
||||
virtual int getType()//devuelve tipo de entidad
|
||||
{
|
||||
return CartoBaseTypes::Point;
|
||||
};
|
||||
|
||||
virtual CartoEntity* set(CartoBaseInfoEntity *src);
|
||||
|
||||
virtual int CopyInTo(CartoBase *src);
|
||||
virtual double* getPto(int i);
|
||||
|
||||
virtual int getNumberPtos(){return 1;}
|
||||
};
|
||||
|
||||
class UTILES_EXPORT CartoLine: public CartoComun, public SetPtsW
|
||||
{
|
||||
public:
|
||||
Cgarray<double[3]> pts;
|
||||
CartoLine(){};
|
||||
|
||||
virtual int getType()//devuelve tipo de entidad
|
||||
{
|
||||
return CartoBaseTypes::Line;
|
||||
};
|
||||
|
||||
virtual CartoEntity* set(CartoBaseInfoEntity *src);
|
||||
virtual int CopyInTo(CartoBase *src);
|
||||
virtual int getNumberPtos(){return pts.n;}
|
||||
virtual double* getPto(int i);
|
||||
virtual bool addPto(double* p);
|
||||
//funciones de geometria----------------------------------
|
||||
void invert();//invierte el sentido de los pts
|
||||
double getLong();
|
||||
double *GetPtoDis(double dis, double *dst, double *distTot = NULL);
|
||||
};
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#if !defined(AFX_SOCK_SIMPLE_H__8491F9CB_65AF_44E1_80A3_52176804CD08__INCLUDED_)
|
||||
#define AFX_SOCK_SIMPLE_H__8491F9CB_65AF_44E1_80A3_52176804CD08__INCLUDED_
|
||||
|
||||
#include <base_head.h>
|
||||
#include "utiles_def.h"
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#endif
|
||||
#define MODULO_CSOCK_CL "Csock_cl"
|
||||
#include <afxsock.h>
|
||||
|
||||
class C_error;
|
||||
//socket cliente---------------------------------
|
||||
class UTILES_EXPORT Csock_cl : public CAsyncSocket
|
||||
{
|
||||
public:
|
||||
//variables----------------------------------
|
||||
BOOL *pirate;
|
||||
BOOL borra_pirate;
|
||||
BYTE *buf;
|
||||
int mb,nb;
|
||||
Package_head_0 cab;
|
||||
C_error* er;
|
||||
int time_sleep;//tiempo espera
|
||||
int intentos;
|
||||
bool creado;
|
||||
//variables aux------------------------------
|
||||
private:
|
||||
BOOL borra_er;
|
||||
//cons---------------------------------------
|
||||
public:
|
||||
Csock_cl(BOOL*sal=NULL,C_error*e=NULL);
|
||||
virtual ~Csock_cl(void);
|
||||
|
||||
//funciones----------------------------------
|
||||
BOOL Create( UINT puerto=0 , int tipo=SOCK_STREAM ,
|
||||
long evento=FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE ,
|
||||
LPCTSTR ip=NULL );
|
||||
|
||||
BOOL conectar(char *ipdot,int puerto);//conecta con un puerto y ip
|
||||
|
||||
BOOL recibe_package(int indice);//recibe package y lo pone en buffer apartir de indice;
|
||||
BOOL envia_package(BYTE* buff, int n, int encrip=0);//envia el buffer en packages si encrip=1 (hacemos encrip1)
|
||||
//funciones auxiliares-----------------------
|
||||
void cuida_buf(int n);//asegura en buf un espacio de n bytes;
|
||||
BOOL recibe(BYTE*b, int n);//recive n bytes y lo pone en b;
|
||||
BOOL envia(BYTE*buff, int n);//envia bytes sin mas;
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
#pragma once
|
||||
#ifndef DijkstraUtiles_h
|
||||
#define DijkstraUtiles_h
|
||||
#include <base_head.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include "mapmatrix.h"
|
||||
#ifndef MAYUSCULO
|
||||
#define MAYUSCULO (double) 1.e+30
|
||||
|
||||
#endif
|
||||
#ifndef MINUSCULO
|
||||
#define MINUSCULO (double) 1.e-20
|
||||
#endif
|
||||
|
||||
#define EXT_ARCH_DIJ_DEFAULT "ndj"
|
||||
#define NOMB_ARCH_DIJ_DEF "snodos_dj"
|
||||
|
||||
/**
|
||||
* Estructura de elemento de la cola para el cálculo de caminos óptimos por Dijkstra
|
||||
*/
|
||||
struct Djkt_elem_cola
|
||||
{
|
||||
int id; //<Id de elemento
|
||||
int id_inci; //<Id del elemento desde el que se ha llegado a id
|
||||
Djkt_elem_cola *sig; //<Puntero al siguiente elemento
|
||||
};
|
||||
#pragma pack(4)
|
||||
/**
|
||||
* Estructura de nodo para el cálculo de caminos óptimos por Dijkstra
|
||||
*/
|
||||
struct Djkt_nodo_0
|
||||
{
|
||||
int id_padre; //<Indice al nodo padre, o nodo hijo en el cálculo del dijsktra invertido
|
||||
float dis; //<Distancia
|
||||
BOOL visto; //<Indica si se ha pasado ya por el nodo
|
||||
};
|
||||
/*
|
||||
* Estructura de ángulos entre conjunciones adyacentes para añadir al Dijkstra el ángulo de giro
|
||||
*/
|
||||
typedef struct Djkt_ids_pdr
|
||||
{
|
||||
int id; //id padre al que tienes que ir
|
||||
float dis; //distancia que vas a recorrer
|
||||
}Djkt_ids_pdr;
|
||||
/*
|
||||
* Estructura de ángulos entre conjunciones adyacentes para añadir al Dijkstra el ángulo de giro
|
||||
*/
|
||||
class UTILES_EXPORT Djkt_ang_ady
|
||||
{
|
||||
public:
|
||||
int nady;
|
||||
Djkt_ids_pdr *ids_padre;
|
||||
int *i_conjs;
|
||||
BYTE **angs;
|
||||
//*******************************************
|
||||
Djkt_ang_ady();
|
||||
void libera();
|
||||
BOOL inicia(int n, BOOL no_angs=FALSE);
|
||||
BOOL dame_ii_jj(int i, int j, int *ii_,int *jj_);
|
||||
BOOL pon_ang_i_j(int i,int j, BYTE ang);
|
||||
BOOL dame_ang_i_j(int i,int j, BYTE *ang, BOOL inds_abs);
|
||||
BOOL pon_padre(int i_orig,int j_padre, double dis, BOOL inds_abs);
|
||||
BOOL dame_padre(int i_orig,int *j_padre, double *dis, BOOL inds_abs);
|
||||
BOOL inicia_ids();
|
||||
void libera_ex();
|
||||
BOOL guarda(HeadCostAng hd, int ic, char *path, char * ext);
|
||||
BOOL lee(int ic, char *path , char * ext);
|
||||
};
|
||||
//*************************************************************************************
|
||||
struct Djkt_nodo: public Djkt_nodo_0
|
||||
{
|
||||
Djkt_ang_ady ids_ady;
|
||||
//Funciones
|
||||
void inicia();
|
||||
BOOL inicia_ex(Djkt_ang_ady *ang);
|
||||
void libera( );
|
||||
};
|
||||
#pragma pack(16)
|
||||
/**
|
||||
* Estructura de cola con prioridad para el cálculo de caminos óptimos por Dijkstra
|
||||
*/
|
||||
struct Djkt_cola
|
||||
{
|
||||
int nn;
|
||||
Djkt_nodo *nodos; //<Puntero a matriz de nodos
|
||||
Djkt_elem_cola *elem; //<Puntero a elementos almacenados
|
||||
//Funciones
|
||||
void inicia(Djkt_nodo *n);
|
||||
BOOL pon(int i);
|
||||
BOOL pon(int i,int i_inci);
|
||||
int dame();
|
||||
int dame(int *id_inci);
|
||||
};
|
||||
//*************************************************************************************
|
||||
class UTILES_EXPORT FlagsArray
|
||||
{
|
||||
public:
|
||||
Cgarray<BYTE> dat;
|
||||
inline BOOL operator[](__int64 i)
|
||||
{
|
||||
BYTE j =(BYTE)(1<<(i%(sizeof(BYTE)*8)));
|
||||
return (BOOL)((dat[(int)(i/(sizeof(BYTE)*8.))] & j) == j);
|
||||
}
|
||||
inline void set(__int64 i, BOOL v)
|
||||
{
|
||||
BYTE j;
|
||||
j =(BYTE)(1<<(i%(sizeof(BYTE)*8)));
|
||||
|
||||
if(!v)
|
||||
{
|
||||
j = ~j;
|
||||
dat[(int)(i/(sizeof(BYTE)*8.))] &= j;
|
||||
return;
|
||||
}
|
||||
dat[(int)(i/(sizeof(BYTE)*8.))] |= j;
|
||||
}
|
||||
|
||||
inline BOOL dimensiona(__int64 n)
|
||||
{
|
||||
dat.n = 0;
|
||||
int nn = (int)(0.5+n/(sizeof(BYTE)*8.));
|
||||
if(!(dat+=nn))
|
||||
return FALSE;
|
||||
dat.n = nn;
|
||||
return TRUE;
|
||||
}
|
||||
inline void setAll(BOOL v)
|
||||
{
|
||||
BYTE j = 0;
|
||||
if(v)
|
||||
j =~j;
|
||||
memset(dat.ptr, j, dat.n*sizeof(BYTE));
|
||||
}
|
||||
};
|
||||
//*************************************************************************************
|
||||
class UTILES_EXPORT DijkstraUtiles
|
||||
{
|
||||
public:
|
||||
static BOOL dijkstra_ang_inv_ok(CmapMatFloat &costes, Djkt_ang_ady *angs, int n, int fin, Djkt_nodo **nodos, FlagsArray *visto_ang_);
|
||||
static double ruta_dj_inv_ok(int id_ini, int *secu, Djkt_nodo *nodos, int nmax, int *n);
|
||||
static double ruta_dj_inv(int id_ini, int *secu, Djkt_nodo *nodos, int nmax, int *n);
|
||||
};
|
||||
|
||||
//*************************************************************************************
|
||||
/**
|
||||
* Clase de manejo de archivos de nodos djtra
|
||||
* cada archivo tiene un numero de bloques o array de nodos de longitud fija "nnod"
|
||||
*/
|
||||
//estructura cabecera de archivo
|
||||
typedef struct Head_dj_arch
|
||||
{
|
||||
int version; //version del archivo
|
||||
int nn; //numero de nodos por bloque
|
||||
int nb; //numero de bloques del dj
|
||||
int max_conex; //maximo de conexiones por nodo
|
||||
|
||||
}Head_dj_arch;
|
||||
#define VERSION_DJ_ARCHI 100
|
||||
#define MAX_CONEX_DJ_ARCHI 16
|
||||
|
||||
class UTILES_EXPORT InfoIndice
|
||||
{
|
||||
public:
|
||||
virtual int get(int iamb, int iextremo) = 0;//da del ambito iamb el indice a inicio o a fin //si iextremo es o o 1
|
||||
};
|
||||
|
||||
class UTILES_EXPORT Cdijkstra_arch
|
||||
{
|
||||
public:
|
||||
char extension[16];//extension de archivos
|
||||
char path[MAX_PATH];//nombre sin extension
|
||||
Head_dj_arch hd;//cabecera de archivo
|
||||
int sizn;//tamaño en BYTES de cada nodo
|
||||
BOOL salta_ids_padres;
|
||||
//int flags;//0x1-->modo escritura 0x2-->modo lectura
|
||||
//info de distancias ambitos
|
||||
float *dis;//distancia de un nodo a otro (matriz de nnod*nnod)
|
||||
int nod_amb;//nodos por ambito
|
||||
int nambi;//numero de ambitos
|
||||
int nnod;//numero de nodos por fila
|
||||
int id_instal;//fila planta
|
||||
int id_plan;//fila instal
|
||||
int nod_instal;//nodo instalacion
|
||||
int nod_plan;//nodo planta
|
||||
int tip_ambitos;
|
||||
|
||||
InfoIndice* ia;//puntero a info asoc
|
||||
|
||||
//funciones--------------------------------------------------------------------------
|
||||
Cdijkstra_arch();
|
||||
~Cdijkstra_arch();
|
||||
|
||||
BOOL inicia(char* path_arch, BOOL nuevo=FALSE, BOOL borra = TRUE, int n_nod=0, int max_conex=MAX_CONEX_DJ_ARCHI);//si nuevo -> crea vacio
|
||||
BOOL add_b(Djkt_nodo* blq, int iref, int inod, BOOL pon_inf=FALSE);//añade un bloque a el archivo
|
||||
BOOL inicia_inf_amb(InfoIndice* ina, int namb,int tip_amb, int id_instal=-1, int id_plan=-1);
|
||||
void pon_info_amb(Djkt_nodo* nodos, int iref,int ib);
|
||||
Djkt_nodo* get_b(int iref, int ibloq, Djkt_nodo* buf=NULL);//develve el bloque ibloq-esimo
|
||||
float dame_dis(int aorig,int norig, int ades, int n_des);
|
||||
|
||||
Djkt_nodo* dame_buf_nodos(BOOL angulos=FALSE );
|
||||
void libera_buf(Djkt_nodo* buf );
|
||||
BOOL graba_dis(int id);
|
||||
BOOL lee_dis();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
#pragma once
|
||||
#ifndef Fdbf_H
|
||||
#define Fdbf_H
|
||||
#include "base_head.h"
|
||||
#include "b_file.h"
|
||||
#include "garray.h"
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct Hdr_dbf
|
||||
{
|
||||
BYTE ver,year,mes,dia; // cuatro primeros bytes
|
||||
long nrec; // nº de records (filas)
|
||||
short nb_cab; // nº de bytes de la cabecera
|
||||
short nb_rec; // nº de bytes de cada record
|
||||
BYTE res[20];
|
||||
} Hdr_dbf;
|
||||
|
||||
typedef struct Fld_dbf
|
||||
{
|
||||
char nombre[11]; // nombre del campo
|
||||
BYTE tipo; // tipo de campo
|
||||
// C caracter
|
||||
// N número
|
||||
// L lógico (Y/N,T/F, y mas)
|
||||
// D fecha (YYYYMMDD)
|
||||
// F float, double
|
||||
BYTE res1[4];
|
||||
BYTE nb; // nº de bytes del campo
|
||||
//Nuevo elena 201709
|
||||
union
|
||||
{
|
||||
BYTE res2[15];
|
||||
struct{
|
||||
|
||||
|
||||
BYTE nd; //nº de decimales
|
||||
BYTE res2_[14];
|
||||
};
|
||||
};
|
||||
} Fld_dbf;
|
||||
|
||||
#pragma pack(8)
|
||||
|
||||
#define DBF_TYPE_DATA_STR 'C'
|
||||
#define DBF_TYPE_DATA_I64 'D'
|
||||
#define DBF_TYPE_DATA_D 'F'
|
||||
#define DBF_TYPE_DATA_BOOL 'L'
|
||||
#define DBF_TYPE_DATA_BIN 'M'
|
||||
#define DBF_TYPE_DATA_I 'N'
|
||||
|
||||
//clase base de dbf-------------------------------------
|
||||
class UTILES_EXPORT Fdbf
|
||||
{
|
||||
Hdr_dbf head;
|
||||
Cgarray<Fld_dbf>colm;
|
||||
Cgarray<char> buf;//buffer de fila
|
||||
Cgarray<char> buf2;//buffer auxi
|
||||
|
||||
Cgarray<int>iniCol;//indice a el bite deonde empieza la columna iesima dentro de una fila
|
||||
Cb_file *f;
|
||||
int nReadRow;//numero de filas leidas actualmente
|
||||
public:
|
||||
Fdbf(void);
|
||||
~Fdbf(void);
|
||||
|
||||
//funciones de lectura
|
||||
bool lee( Cb_file *file);
|
||||
int leeNexRow();//devuelve 1 si ok 0 si no mas -1 si error
|
||||
|
||||
double getD(int ncol);
|
||||
int getI(int ncol);
|
||||
char* getStr(int ncol);
|
||||
__int64 getI64(int ncol);
|
||||
char* get(int ncol);//devuelve buffer tal cual
|
||||
|
||||
BYTE getType(int ncol);
|
||||
char* getName(int ncol);
|
||||
int findCol(char *name);
|
||||
|
||||
int getSize(int ncol);
|
||||
int getNrow();
|
||||
int getNcolm();
|
||||
//funciones de escritura
|
||||
bool set(int ncol, int nRow, Cb_file *file);
|
||||
bool setCol(int icol, char *name, BYTE type, int size, int ndecimals=0);
|
||||
|
||||
bool addVal(int icol, int v);
|
||||
bool addVal(int icol, double v);
|
||||
bool addVal(int icol, __int64 v);
|
||||
bool addVal(int icol, char* v);
|
||||
bool addVal(int icol, void* v);
|
||||
bool finRow();
|
||||
|
||||
private:
|
||||
bool bufMem(int ncol);
|
||||
bool iniciaRecords();
|
||||
};
|
||||
|
||||
//clase lisener de lectura
|
||||
class UTILES_EXPORT ListenerDbf_W
|
||||
{
|
||||
public:
|
||||
virtual bool DbfSet(int nrow, int ncolm){return true;}
|
||||
virtual bool DbfSetColm(char* name, BYTE type, int size){return true;}
|
||||
virtual bool DbfaddVal(int icol, int v){return true;}
|
||||
virtual bool DbfaddVal(int icol, double v){return true;}
|
||||
virtual bool DbfaddVal(int icol, __int64 v){return true;}
|
||||
virtual bool DbfaddVal(int icol, char* v){return true;}
|
||||
virtual bool DbfaddVal(int icol, void* v){return true;}
|
||||
virtual bool DbfFinRow(){return true;}
|
||||
virtual bool DbfFinR(){return true;}
|
||||
|
||||
};
|
||||
//clase lisener de escritura
|
||||
class UTILES_EXPORT ListenerDbf_R
|
||||
{
|
||||
public:
|
||||
virtual bool DbfGet(int *nrow, int *ncolm){return false;}
|
||||
virtual bool DbfGetColm(int icol, char* name, BYTE *type, int *size, int*ndecimal){return false;}
|
||||
virtual bool DbfGetVal(int irow, int icol, int* v){return false;}
|
||||
virtual bool DbfGetVal(int irow, int icol, double* v){return false;}
|
||||
virtual bool DbfGetVal(int irow, int icol, __int64* v){return false;}
|
||||
virtual bool DbfGetVal(int irow, int icol, char** v){return false;}
|
||||
virtual bool DbfGetVal(int irow, int icol, void** v){return false;}
|
||||
virtual bool DbfFinW(){return false;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//clase manager dbf-------------------------
|
||||
class UTILES_EXPORT ManagerDbf
|
||||
{
|
||||
public:
|
||||
static bool leer(Cb_file *file, ListenerDbf_W* lr);
|
||||
static bool grabar(Cb_file *file, ListenerDbf_R* lw);
|
||||
|
||||
static bool leer(char* file, ListenerDbf_W* lr);
|
||||
static bool grabar(char* file, ListenerDbf_R* lw);
|
||||
};
|
||||
|
||||
#endif
|
||||
/*
|
||||
ejemplo de uso--------------------------------
|
||||
escritura---------
|
||||
if(!f.abre("d:\\temp\\p2.dbf",2,true))
|
||||
error =true;
|
||||
if(!dbf.set(3,5,&f))
|
||||
error = true;
|
||||
if(!dbf.setCol(0,"id",DBF_TYPE_DATA_I,10))
|
||||
error = true;
|
||||
if(!dbf.setCol(1,"idf",DBF_TYPE_DATA_D,10,3))
|
||||
error = true;
|
||||
if(!dbf.setCol(2,"str",DBF_TYPE_DATA_STR,128))
|
||||
error = true;
|
||||
for(int i =0; i<5; i++)
|
||||
{
|
||||
if(!dbf.addVal(0,i))
|
||||
error = true;
|
||||
if(!dbf.addVal(1,i+(i*1./10)))
|
||||
error = true;
|
||||
if(!dbf.addVal(2,"holaHolita"))
|
||||
error = true;
|
||||
if(!dbf.finRow())
|
||||
error = true;
|
||||
}
|
||||
f.cierra();
|
||||
//lectura
|
||||
if(!f.abre("d:\\temp\\p2.dbf",1))
|
||||
error =true;
|
||||
if(!dbf.lee(&f))
|
||||
error = true;
|
||||
idd =dbf.leeNexRow();
|
||||
while(idd ==1)
|
||||
{
|
||||
int ii = dbf.getI(0);
|
||||
double d= dbf.getD(1);
|
||||
char* ss = dbf.getStr(2);
|
||||
|
||||
ii++;
|
||||
d++;
|
||||
ss[0]=0;
|
||||
idd =dbf.leeNexRow();
|
||||
}
|
||||
*/
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
#ifndef GdataTable_h
|
||||
#define GdataTable_h
|
||||
//tabla de datos generica
|
||||
//tabla con nombre de columnas
|
||||
#include "base_head.h"
|
||||
#include "garray.h"
|
||||
#include "StrArray.h"
|
||||
class UTILES_EXPORT GdataTableColum
|
||||
{
|
||||
public:
|
||||
int type;//tipo de dato
|
||||
int nb;//numero de bytes de informacion
|
||||
int flags;
|
||||
};
|
||||
|
||||
class UTILES_EXPORT GdataTable
|
||||
{
|
||||
Cgarray<void*>buf; //array de Garray de datos
|
||||
Cgarray<GdataTableColum>colm; //datos de columnas
|
||||
StrArray colmName; //nombre de columnas
|
||||
|
||||
public:
|
||||
enum TypedataTable
|
||||
{
|
||||
Tndef=0,
|
||||
Tbool,
|
||||
Tint,
|
||||
Tdouble,
|
||||
Tint64,
|
||||
Tstring,
|
||||
Tbin,
|
||||
Tntip
|
||||
};
|
||||
GdataTable(void);
|
||||
~GdataTable(void);
|
||||
|
||||
//funciones de lectura y set------------
|
||||
int getType(int icol);
|
||||
int getInd(char* colName);
|
||||
int nRow();
|
||||
int nColm();
|
||||
int getSize(int icol);
|
||||
int getSizeASCII(int icol);
|
||||
|
||||
char* getName(int icol);
|
||||
bool rename(int icol, char* nomb);
|
||||
int* getI(int row, int colm);
|
||||
__int64* getI64(int row, int colm);
|
||||
double* getD(int row, int colm);
|
||||
char* getS(int row, int colm);
|
||||
void* getBin(int row, int colm);
|
||||
bool* getBool(int row, int col);
|
||||
|
||||
void* get(int row, int colm);
|
||||
//funciones de modificacion-------------
|
||||
|
||||
//adicionar-----------------------------
|
||||
bool addColm(char* name, int type, int size=0);
|
||||
bool addRow(int nrow);
|
||||
bool addMemRow(int nrow);
|
||||
//borrado-------------------------------
|
||||
void delAllRow();//borra todas las filas
|
||||
void delAll();//borra todo
|
||||
|
||||
void removeRow(int i);
|
||||
void removeColm(int i);
|
||||
|
||||
//ajusta memoria
|
||||
void clear();
|
||||
//funciones auxiliares--------------------
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
#pragma once
|
||||
#ifndef GeometriFunction_h
|
||||
#define GeometriFunction_h
|
||||
#include "base_head.h"
|
||||
#include "cartoBaseDef.h"
|
||||
#include "garray.h"
|
||||
|
||||
class UTILES_EXPORT GeometryFunction
|
||||
{
|
||||
public:
|
||||
//distancia entre 2 ptos
|
||||
static double Dist2d(double*p1, double*p2);
|
||||
//longitud de la linea
|
||||
static double LongLine2d(SetPtsR *line);
|
||||
//distancia de un punto p a una linea infinita de puntos l1 y l2
|
||||
static double Dpline(double* l1, double *l2, double *p, double *lamb = 0);
|
||||
//distancia de punto p a segmento s1-s2
|
||||
static double DpSeg(double* s1, double *s2, double *p, double *lamb = 0);
|
||||
//interseccion entre lineas (formada por l11-l12) a otra linea (formada por l21-l22)
|
||||
static double* intersecLine(double* l11, double *l12, double* l21, double *l22, double *p_inters);
|
||||
//distancia entre linea (l1-l2)y segmento(s1,s2)
|
||||
static double DLineSeg(double* l1, double *l2, double* s1, double *s2, double *lamdl,double *lambs, bool*paralelos );
|
||||
|
||||
//distancia entre linea (l1-l2)y segmento(s1,s2)
|
||||
static double DsegSeg(double* s11, double *s12, double* s21, double *s22, double *lamd1,double *lamb2);
|
||||
//distancia de polilinea a segmento
|
||||
static double DplineSeg(SetPtsR* line1, double* s1, double *s2,int *n=NULL, double *lamd1=NULL,double *lamb2=NULL);
|
||||
|
||||
|
||||
//calcula coordenadas minimas y maximas
|
||||
static void CompMima(double dst[2][3], SetPtsR* pts);
|
||||
//calcula envoltura convexa
|
||||
static Cgarray<double[3]>* EnvConvex(SetPtsR* pts, Cgarray<double[3]>* dst);
|
||||
//distancia de un punto a una linea
|
||||
static double DisPtoLine(SetPtsR* line, double*p, int* idpto=NULL, double *lamb=NULL);
|
||||
//distancia media entre dos líneas
|
||||
static double DisMedLines( SetPtsR* line1, SetPtsR* line2, double *desv=NULL);
|
||||
static double DisMedLines( SetPtsR* line1, SetPtsR* line2, double l_avan, double *desv=NULL);
|
||||
//parte una linea en 2
|
||||
static bool DivLine(SetPtsR* linesrc, SetPtsW* ldst1, SetPtsW* ldst2, double dis);
|
||||
//dado el ip y el lamb da la distancia desde el principio de la linea
|
||||
static double DisInLine(SetPtsR* linesrc, int ip, double lamb);
|
||||
//dado el ip y el lamb da la distancia desde el punto contenido en la línea
|
||||
static double *PtInLine( SetPtsR* linesrc, int ip, double lamb , double *pp );
|
||||
//devuelve los nptos primeros puntos de line, equiespaciados dis
|
||||
//si avanza, los coge del principio, si no, del final
|
||||
static SetPtsW *GetNPrimePtos(SetPtsR* line, SetPtsW *ldst, int nptos, double dis, BOOL avanza);
|
||||
|
||||
//divide la linea en partes equidistantes
|
||||
static bool DivLine(SetPtsR* line, SetPtsWBuilder *manager, double dis);
|
||||
|
||||
//devuelve el punto que esta en la polilinea a una distancia dist
|
||||
static double* GetPto(SetPtsR* line, double dis, double *dst, double *distTot = NULL);
|
||||
|
||||
static double ang_vect_ptos(double (*ptos1)[][3], double (*ptos2)[][3]);
|
||||
|
||||
//devuelve el angulo que forman los 2 vectores
|
||||
static double AngVect(double v1[2], double v2[2]);
|
||||
//dice si el punto p esta a la derecha de la linea que forman los puntos ip1 y ip2
|
||||
static bool IsDer(SetPtsR* ptos, double *p, int ip1, int ip2);
|
||||
static double ProdEscalar(SetPtsR* line1, SetPtsR* line2);
|
||||
|
||||
//funcion auxiliar potencia
|
||||
static inline double Poten(double bas, int exp = 2)
|
||||
{
|
||||
if(exp<=0)
|
||||
return 0;
|
||||
double res = bas;
|
||||
while(exp>1)
|
||||
{
|
||||
res = res * bas;
|
||||
exp--;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef IaDataTable_h
|
||||
#define IaDataTable_h
|
||||
#include "gdatatable.h"
|
||||
#include "base_head.h"
|
||||
#include "CartoBaseDef.h"
|
||||
#include <map>
|
||||
class CartoBase;
|
||||
//tabla de datos para albergar informacion asiciada generica (diseñada para el cartobase)
|
||||
class UTILES_EXPORT IaDataTable :
|
||||
public GdataTable, public DataIaCartoBase
|
||||
{
|
||||
std::map<int, int> RefIndex;//indexado por referencias;
|
||||
std::map<int, int> rowIndex;//indexado por filas;
|
||||
CartoBase* _cb;
|
||||
int auxnrow,auxcolm,auxref,auxc;
|
||||
public:
|
||||
IaDataTable(void);
|
||||
~IaDataTable(void);
|
||||
|
||||
virtual void* IaGet( int refEnt );
|
||||
virtual void CBSet( CartoBase* cb );
|
||||
virtual void IaRemove( int refEnt );
|
||||
virtual void IaRemoveAll();
|
||||
virtual void IaAdd( int refEnt );
|
||||
virtual bool IaSet( int nrow, int ncolm );
|
||||
virtual bool IaSetColm( int icol, char* name, BYTE type, int size );
|
||||
virtual bool IaAddVal( int refEnt, int icol, int v );
|
||||
virtual bool IaAddVal( int refEnt, int icol, double v );
|
||||
virtual bool IaAddVal( int refEnt, int icol, __int64 v );
|
||||
virtual bool IaAddVal( int refEnt, int icol, char* v );
|
||||
virtual bool IaAddVal( int refEnt, int icol, void* v );
|
||||
virtual bool IaFinRow( int refEnt );
|
||||
virtual bool IaFinR();
|
||||
virtual bool IaGetSize( int *ncolm );
|
||||
virtual bool IaGetColm( int icol, char* name, BYTE *type, int *size, int*ndecimal );
|
||||
virtual bool IaGetVal( int refEnt, int icol, int* v );
|
||||
virtual bool IaGetVal( int refEnt, int icol, double* v );
|
||||
virtual bool IaGetVal( int refEnt, int icol, __int64* v );
|
||||
virtual bool IaGetVal( int refEnt, int icol, char** v );
|
||||
virtual bool IaGetVal( int refEnt, int icol, void** v );
|
||||
virtual bool IaFinW();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef ManagerDbfGdataTable_H
|
||||
#define ManagerDbfGdataTable_H
|
||||
|
||||
#include "base_head.h"
|
||||
#include "Fdbf.h"
|
||||
|
||||
class IAddColDbf
|
||||
{
|
||||
public:
|
||||
int size = 0;
|
||||
virtual void setData(int i, void *data)=0;
|
||||
};
|
||||
class GdataTable;
|
||||
class UTILES_EXPORT ManagerDbfGdataTable: public ListenerDbf_W, public ListenerDbf_R
|
||||
{
|
||||
|
||||
GdataTable *_dt;
|
||||
int _nrow;
|
||||
int _ncolm;
|
||||
public:
|
||||
ManagerDbfGdataTable(void);
|
||||
~ManagerDbfGdataTable(void);
|
||||
|
||||
bool LeeDbf(char* path, GdataTable *dt);
|
||||
bool grabaDbf(char* path, GdataTable *dt);
|
||||
bool AddCol( char* path, char* name, BYTE type,IAddColDbf *dt, int size=0);
|
||||
bool DelCol(char* path, char* name);
|
||||
|
||||
//funciones de herencia----------------------------------------
|
||||
//LisenerDbf_R-------------------------------------------------
|
||||
virtual bool DbfSet( int nrow, int ncolm );
|
||||
virtual bool DbfSetColm( char* name, BYTE type, int size );
|
||||
virtual bool DbfaddVal( int icol, int v );
|
||||
virtual bool DbfaddVal( int icol, double v );
|
||||
virtual bool DbfaddVal( int icol, __int64 v );
|
||||
virtual bool DbfaddVal( int icol, char* v );
|
||||
virtual bool DbfaddVal( int icol, void* v );
|
||||
virtual bool DbfFinRow();
|
||||
virtual bool DbfFinR();
|
||||
//LisenerDbf_W----------------------------------------------------
|
||||
virtual bool DbfGet( int *nrow, int *ncolm );
|
||||
virtual bool DbfGetColm(int icol, char* name, BYTE *type, int *size, int*ndecimal );
|
||||
virtual bool DbfGetVal(int irow, int icol, int* v );
|
||||
virtual bool DbfGetVal(int irow, int icol, double* v );
|
||||
virtual bool DbfGetVal(int irow, int icol, __int64* v );
|
||||
virtual bool DbfGetVal(int irow, int icol, char** v );
|
||||
virtual bool DbfGetVal(int irow, int icol, void** v );
|
||||
virtual bool DbfFinW();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef Matrix2d_h
|
||||
#define Matrix2d_H
|
||||
|
||||
#include "b_file.h"
|
||||
#include "garray.h"
|
||||
//matiz de clases genericas de 2 dimensiones
|
||||
template <typename Tc>
|
||||
class ComClasFunction
|
||||
{
|
||||
public:
|
||||
virtual Tc comp(Tc a, Tc b) = 0;
|
||||
};
|
||||
template <typename ClasVal>
|
||||
class Matrix2d
|
||||
{
|
||||
Cgarray<ClasVal> dat;
|
||||
int ysize;
|
||||
public:
|
||||
Matrix2d()
|
||||
{
|
||||
ysize = 0;
|
||||
}
|
||||
bool inline inicia(int xmax, int ymax)
|
||||
{
|
||||
ysize = ymax;
|
||||
dat.borra();
|
||||
if(!(dat+=xmax*ymax))
|
||||
return false;
|
||||
dat.n = xmax*ymax;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline ClasVal* operator[](int x)//devuelve puntero a fila x
|
||||
{
|
||||
return dat.get(x*ysize);
|
||||
}
|
||||
|
||||
//*******************************************************************************************************
|
||||
|
||||
inline bool graba( char* path )
|
||||
{
|
||||
Cb_file file;
|
||||
if(!file.abre(path,2,TRUE))
|
||||
return false;
|
||||
if(!file.escribe(&ysize, sizeof(ysize)))
|
||||
return false;
|
||||
if(!dat.graba(&file))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
inline bool lee( char* path )
|
||||
{
|
||||
Cb_file file;
|
||||
if(!file.abre(path,1,FALSE,TRUE))
|
||||
return false;
|
||||
if(!file.lee(&ysize, sizeof(ysize)))
|
||||
return false;
|
||||
if(!dat.leer(&file))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
inline void clear()
|
||||
{
|
||||
dat.borra();
|
||||
}
|
||||
inline bool fileMix( char* path, ComClasFunction<ClasVal> *ccomp )
|
||||
{
|
||||
if(ysize<=0)
|
||||
return false;
|
||||
Cgarray<ClasVal> fdat;
|
||||
int yfile, xfile;
|
||||
Cb_file file;
|
||||
if(!file.abre(path,1,FALSE,TRUE))
|
||||
return false;
|
||||
//lee tamaño matriz
|
||||
if(!file.lee(&yfile, sizeof(yfile)))
|
||||
return false;
|
||||
if(!file.lee(&xfile, sizeof(xfile)))
|
||||
return false;
|
||||
xfile = xfile/yfile;
|
||||
//inicia buffer
|
||||
if(!(fdat+=yfile))
|
||||
return false;
|
||||
//calcula numero de bytes a leer y margenes de matriz
|
||||
int nb = sizeof(ClasVal)*yfile;
|
||||
xfile = min(xfile, dat.n/ysize);
|
||||
yfile = min(yfile, ysize);
|
||||
for(int x = 0 ; x<xfile; x++)
|
||||
{
|
||||
//lee fila
|
||||
if(!file.lee(fdat.ptr, nb))
|
||||
return false;
|
||||
//realiza el mix
|
||||
for(int y = 0; y< yfile; y++)
|
||||
dat.get(x*ysize)[y] = ccomp->comp(dat.get(x*ysize)[y], fdat[y]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
#ifndef StrArray_h
|
||||
#define StrArray_H
|
||||
|
||||
#include "base_head.h"
|
||||
class UTILES_EXPORT StrArray
|
||||
{
|
||||
//variables------------------------------
|
||||
int incremento_char;
|
||||
int incremento_str;
|
||||
public:
|
||||
char *str;
|
||||
int n_str;//numero de chars
|
||||
int m_str;//memoria reser
|
||||
int (*ind)[];
|
||||
int n_i;//numero de str
|
||||
int m_i;//memoria reser
|
||||
//constructor----------------------------
|
||||
public:
|
||||
StrArray(void);
|
||||
~StrArray(void);
|
||||
//funciones------------------------------
|
||||
char* get(int i);//da string i
|
||||
void add(char*c);//mete str
|
||||
void add(char*c, int ncharReser);//mete str y reserva en memoria un minimo de ncharReser;
|
||||
void add( StrArray* st );//mete un array entero de caracteres
|
||||
void borra(int i);//borra el elemento iesimo
|
||||
int size();//da numero de str
|
||||
void borra();//borra todo
|
||||
void compacta();//reduce al minimo la memoria necesaria para comtener la informacion
|
||||
StrArray* filtra(StrArray*buf, char *filter);
|
||||
BOOL replace(int i, char* cadena);
|
||||
int find(char* st);
|
||||
//funciones aux-------------------------
|
||||
private:
|
||||
void cuida_memoria(int n,int ni=1);//asegura tener memoria para un str mas
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
#include <base_head.h>
|
||||
#include "th.h"
|
||||
#ifndef TaskProcess_h
|
||||
#define TaskProcess_h
|
||||
/*
|
||||
Tarea delegada en otro proceso(normalmente en programa de consola)
|
||||
definir en funcion override run la tarea
|
||||
*/
|
||||
class Csock_cl;
|
||||
class UTILES_EXPORT TaskProcess: public Cth
|
||||
{
|
||||
Csock_cl *sc;
|
||||
public:
|
||||
bool pirate;//indica que hay que irse
|
||||
|
||||
TaskProcess(void);
|
||||
~TaskProcess(void);
|
||||
bool initTask(char* url, int port, __int64 timer);
|
||||
bool envia(void * buf, int nb);//envia buffer al proceso principal
|
||||
void* recibe(int *nb );//recibe del proceso principal nb da el numero de bytes recib
|
||||
//overrides----------------------------------
|
||||
void cancela();//cancela tarea;
|
||||
virtual void preTask()=0;
|
||||
virtual void inTask()=0;
|
||||
virtual void postTask()=0;
|
||||
|
||||
virtual bool conecta(char* url, int port);
|
||||
virtual void desconecta();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include <afxwinappex.h>
|
||||
#include "_error.h"
|
||||
#include "dir_manager.h"
|
||||
#include "_log.h"
|
||||
|
||||
class UTILES_EXPORT C_app //clase aplicacion----
|
||||
{
|
||||
static C_app *p_app;//puntero a la clase aplicacion
|
||||
|
||||
public:
|
||||
//variables globales-----------------------
|
||||
Cdir_manager archi;//manager de archivos
|
||||
C_log log;//clase de trazas (log)
|
||||
C_error er;//clase de manejo de errores;
|
||||
//variables de thread;
|
||||
BOOL pirate;//indica a los thread que hay que irse
|
||||
long nth;//indica el numero de thread que hay activos
|
||||
C_app(void);
|
||||
virtual ~C_app(void);
|
||||
//funciones y overrides------------
|
||||
static C_app* GetApp();
|
||||
BOOL inicio();
|
||||
int fin();
|
||||
void suma_th();//añade al conteo de thread +1
|
||||
void resta_th();//disminulle el conteo de thread en 1
|
||||
virtual BOOL on_inicia();//funcion inicia lo necesario para el programa
|
||||
virtual BOOL on_cierra();//funcion que se ejecuta al final del todo antes de cerrar
|
||||
|
||||
virtual void cierra();//fuerza el fin de la aplicacion;
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
|
||||
class UTILES_EXPORT C_error
|
||||
{
|
||||
public:
|
||||
//variables-----------------------------
|
||||
char modulo[32];//parte del programa que causa el error
|
||||
char msg[256];//mensaje de error
|
||||
int tipo;//codigo de error
|
||||
//constructor---------------------------
|
||||
C_error(void);
|
||||
virtual ~C_error(void);
|
||||
//funciones-----------------------------
|
||||
void pon(char *mod, char *mens, int tip=-1);//pone error propio
|
||||
void pon_win(char *modulo);//pone error windows
|
||||
void aclara(char *mens);//pone aclaracion
|
||||
void limpia();//limpia error
|
||||
};
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "lock.h"
|
||||
#include <string>
|
||||
typedef struct Msg_evento_log
|
||||
{
|
||||
int id_e;
|
||||
char nivel[64];
|
||||
char mensage[256];
|
||||
__time64_t tiempo;
|
||||
}Msg_evento_log;
|
||||
class C_error;
|
||||
class UTILES_EXPORT C_escucha_log//clase para escuchar eventos de log
|
||||
{
|
||||
public:
|
||||
virtual void log_ext(__time64_t tiemp, char *modulo, char *fmt)=0;
|
||||
};
|
||||
class UTILES_EXPORT C_log//clase para logear eventos
|
||||
{
|
||||
public:
|
||||
//variavles-----------------------------------------
|
||||
HFILE archivo_log;
|
||||
int nb;
|
||||
Clock cerrojo;
|
||||
C_escucha_log *l_lisener;//puntero a escucha actual
|
||||
//BOOL log_consola;
|
||||
char nombre[32];
|
||||
char path[256];
|
||||
|
||||
void (*log_ext)(__time64_t tiemp, char *modulo, char *fmt);//funcion de log externa
|
||||
C_log(void);
|
||||
~C_log(void);
|
||||
//funcion-------------------------------------------
|
||||
void loguea(__time64_t tiemp, char *modulo, char *fmt);//añade un suceso
|
||||
void loguea(char *modulo, char *fmt);//añade suceso actual
|
||||
void loguea(C_error *er);//añade el error como suceso
|
||||
static void log(char *modulo, char *fmt,...);//funcion estatica para loguear
|
||||
static void log( C_error *er );
|
||||
//static void log(std::string &mod, std::string &msg);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
|
||||
const DWORD MS_VC_EXCEPTION_PROCESO_UTILES=0x406D1388;
|
||||
|
||||
#pragma pack(push,8)
|
||||
typedef struct tagTHREADNAME_INFO
|
||||
{
|
||||
DWORD dwType; // Must be 0x1000.
|
||||
LPCSTR szName; // Pointer to name (in user addr space).
|
||||
DWORD dwThreadID; // Thread ID (-1=caller thread).
|
||||
DWORD dwFlags; // Reserved for future use, must be zero.
|
||||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
|
||||
class UTILES_EXPORT C_proceso//proceso base
|
||||
{
|
||||
public:
|
||||
C_proceso(void);
|
||||
char nombre[32];
|
||||
CWinThread * m_thread;
|
||||
virtual ~C_proceso(void);
|
||||
BOOL lanza(char *nombre=NULL);//lanzar thread
|
||||
virtual void run();//funcion que hace el thread
|
||||
void join();//espera al thread
|
||||
};
|
||||
UINT main_c_proceso(LPVOID pp);
|
||||
UTILES_EXPORT void SetThreadName( DWORD dwThreadID, char* threadName);
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "_error.h"
|
||||
#include "utiles_def.h"
|
||||
class UTILES_EXPORT Cb_file: public IdataTransfer//manejo de archivos binarios
|
||||
{
|
||||
private:
|
||||
HANDLE hfile;//hanled del archivo
|
||||
LARGE_INTEGER li;//se usa para dividir enteros de 64
|
||||
DWORD dw;//bites movidos y respuestas al escribir
|
||||
public:
|
||||
C_error *er;
|
||||
|
||||
Cb_file(void);
|
||||
~Cb_file(void);
|
||||
//******************************************************************************************************************
|
||||
//funciones--------------------------------------------------------------------
|
||||
//******************************************************************************************************************
|
||||
inline BOOL abierto()
|
||||
{
|
||||
return hfile != INVALID_HANDLE_VALUE;
|
||||
};
|
||||
//******************************************************************************************************************
|
||||
BOOL abre(char* path,int modo, BOOL sobre_escri=FALSE, BOOL shared=FALSE);//modo 1 lectura modo 2 escritura modo 3 ambos
|
||||
//******************************************************************************************************************
|
||||
inline void cierra()//cierra archivo;
|
||||
{
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
QWORD size();//te devuelve el tamaño del archivo en bytes
|
||||
//******************************************************************************************************************
|
||||
inline BOOL lee(void* buf,int nb)//lee un numero de bites y lo pone en buf
|
||||
{
|
||||
if (!ReadFile(hfile, (LPSTR) buf ,nb,&dw,NULL))
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
inline BOOL escribe(void* buf,int nb)//escribe numero de bites
|
||||
{
|
||||
if (!WriteFile(hfile, (LPSTR) buf ,nb,&dw,NULL))
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
inline BOOL irAfin()//va a la posicion del final del archivo
|
||||
{
|
||||
dw=SetFilePointer(hfile,0,NULL,FILE_END);
|
||||
if(dw==INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
BOOL irAini(int nb=0)//va al inicio del archivo + nb bytes;
|
||||
{
|
||||
|
||||
dw=SetFilePointer(hfile,nb,NULL,FILE_BEGIN);
|
||||
if(dw==INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
BOOL irA(int nb=0)//salta nbites;
|
||||
{
|
||||
|
||||
dw=SetFilePointer(hfile,nb,NULL,FILE_CURRENT);
|
||||
if(dw==INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
inline BOOL irAini( QWORD nb)//entero de 64 bytes
|
||||
{
|
||||
li.QuadPart = nb;
|
||||
dw=SetFilePointer(hfile,li.LowPart,&li.HighPart,FILE_BEGIN);
|
||||
if(dw==INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
if (er)
|
||||
er->pon_win("Cb_file");
|
||||
//cierra---------------------
|
||||
if (hfile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(hfile);
|
||||
hfile=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
//---------------------------
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
virtual __int64 getNB_it()
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
||||
virtual __int64 getNext_it( void* buf,__int64 nb )
|
||||
{
|
||||
if(lee(buf,(int)nb))
|
||||
return nb;
|
||||
return -1;
|
||||
}
|
||||
|
||||
virtual bool setPosition_it( __int64 nb )
|
||||
{
|
||||
return irAini((int)nb) ==TRUE;
|
||||
}
|
||||
|
||||
virtual bool set_it( void* buf, __int64 nb )
|
||||
{
|
||||
return escribe(buf,(int)nb) == TRUE;
|
||||
}
|
||||
//******************************************************************************************************************
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef UTILES_EXPORT
|
||||
#ifdef _WINDLL
|
||||
#define UTILES_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define UTILES_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 0xffff
|
||||
#endif
|
||||
#ifdef _WIN64
|
||||
typedef __int64 ssize_t;
|
||||
#else
|
||||
typedef _w64 int ssize_t;
|
||||
|
||||
#endif
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
|
||||
class C_error;
|
||||
class StrArray;
|
||||
class UTILES_EXPORT Cdir_manager//clase para manejar carpetas
|
||||
{
|
||||
public:
|
||||
|
||||
//carpetas-------------------------------------------------------
|
||||
char dir_work[FILENAME_MAX];
|
||||
char dir_exe[FILENAME_MAX];
|
||||
char dir_log[FILENAME_MAX];
|
||||
char dir_datos[FILENAME_MAX];
|
||||
//archivos-------------------------------------------------------
|
||||
char path_conf[FILENAME_MAX];
|
||||
//rutas de ejecucion---------------------------------------------
|
||||
char dir_ejecucion[FILENAME_MAX];
|
||||
char path_ejecutable[FILENAME_MAX];
|
||||
//funciones------------------------------------------------------
|
||||
Cdir_manager(void);
|
||||
~Cdir_manager(void);
|
||||
//funciones------------------------------------------------------
|
||||
void absoluta(char *ruta);
|
||||
void relativa(char *ruta);
|
||||
|
||||
BOOL lee_reg(char* clave, C_error *er=NULL);
|
||||
BOOL rellena_dirs_ejecucion();
|
||||
//funciones estaticas---------------------------------------
|
||||
static char* dir_anterior(char*dir);//da el directorio anterior
|
||||
static char* nombre_archivo(char *path,char*nombre);//devuelve en nombre el nombre del archivo
|
||||
static char* extension_archivo(char *path);//te da la extension de un path o de un nombre de archivo
|
||||
static char* cambia_extension_archivo(char *path, char *pathDst, char *newext);//te da la extension de un path o de un nombre de archivo
|
||||
static BOOL crea_dir(char *path);//asegura que existe los directorios indicados
|
||||
static BOOL borra_archivos(char *paht, char *ext, BOOL recursivo = FALSE);//borra archivos de una extension dada, si ext es null borra todos
|
||||
//funciones de listado-----------
|
||||
static BOOL listar_elementos(char *dir,StrArray *files,StrArray *dirs,C_error *er=NULL);//dice los files y las dir dentro de un dir(no recursivo)
|
||||
static BOOL lista_files(char *dir,StrArray *files,BOOL recursivo=FALSE,C_error *er=NULL,char *omite=NULL);
|
||||
|
||||
static BOOL listar( char* dir,StrArray *files,StrArray *dirs=NULL,BOOL recursivo=FALSE,C_error *er=NULL,char *omite=NULL );//funcion generica de listar
|
||||
//devuelve version de el archivo
|
||||
static char* getVersionFile(char *path, char *buf);//buffer de 64 sobra
|
||||
};
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
|
||||
#pragma once
|
||||
#ifndef Cgarray_H
|
||||
#define Cgarray_H
|
||||
|
||||
#define GARRAY_INCREMENT 100
|
||||
#include "b_file.h"
|
||||
//array generico---------------------------------
|
||||
/*
|
||||
Clase para manejar arrays genericos de cualquier tipo de clase o estructura
|
||||
*/
|
||||
template <typename T>
|
||||
class Cgarray
|
||||
{
|
||||
public:
|
||||
//variables----------------------------------------------------------------------------------
|
||||
int m; //cache del array
|
||||
int n; //numero de elementos en array
|
||||
int increment; //valor a incrementar en la cache
|
||||
T* ptr; //array de elementos
|
||||
//**************************************************************
|
||||
//constructores-------------------------------------------------------------------------------
|
||||
//**************************************************************
|
||||
Cgarray()
|
||||
{
|
||||
m=0;
|
||||
ptr=NULL;
|
||||
n=0;
|
||||
increment=GARRAY_INCREMENT;
|
||||
};
|
||||
//**************************************************************
|
||||
Cgarray(int cache)//constructor poniendo en memoria posiciones
|
||||
{
|
||||
m=cache;
|
||||
ptr=(T*)malloc(sizeof(T)*m);
|
||||
if (ptr)
|
||||
memset(ptr,0,m * sizeof(T));
|
||||
else
|
||||
m=0;
|
||||
n=0;
|
||||
increment=GARRAY_INCREMENT;
|
||||
};
|
||||
//**************************************************************
|
||||
~Cgarray()
|
||||
{
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
};
|
||||
//**************************************************************
|
||||
//funciones-----------------------------------------------------------------------------------
|
||||
//**************************************************************
|
||||
inline T& operator[](int i)//da el elemento i-esimo por referencia
|
||||
{
|
||||
return ptr[i];
|
||||
};
|
||||
//**************************************************************
|
||||
inline T* get(int i)//da el elemento i-esimo
|
||||
{
|
||||
return &ptr[i] ;
|
||||
};
|
||||
//**************************************************************
|
||||
inline void remove(int ini, int nelem = 1)
|
||||
{
|
||||
if(ini<0)
|
||||
ini =0;
|
||||
if(ini>=n || nelem<1)
|
||||
return;
|
||||
int fin = ini+nelem;
|
||||
if(fin>=n)
|
||||
{
|
||||
n =ini;
|
||||
return;
|
||||
}
|
||||
|
||||
memmove(&ptr[ini], &ptr[fin], (n-fin)*sizeof(T));
|
||||
n-=(fin-ini);
|
||||
};
|
||||
//**************************************************************
|
||||
inline BOOL operator+(T &e )//añade nuevo elemento
|
||||
{
|
||||
T*pp;
|
||||
if (m<n+1)
|
||||
{
|
||||
m+=increment;
|
||||
if (ptr)
|
||||
pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
else
|
||||
pp=(T*)malloc(sizeof(T)*m);
|
||||
if (!pp)
|
||||
{
|
||||
m-=increment;
|
||||
return FALSE;
|
||||
}
|
||||
ptr=pp;
|
||||
memset(&ptr[m-increment],0,increment);
|
||||
}
|
||||
ptr[n]=e;
|
||||
n++;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
inline BOOL operator+=(int mas )//añade memoria para mas elementos
|
||||
{
|
||||
T*pp;
|
||||
int inc=n+mas-m;
|
||||
if (inc>0)
|
||||
{
|
||||
if (inc<increment)
|
||||
inc=increment;
|
||||
m+=inc;
|
||||
if (ptr)
|
||||
pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
else
|
||||
pp=(T*)malloc(sizeof(T)*m);
|
||||
if (!pp)
|
||||
{
|
||||
m-=inc;
|
||||
return FALSE;
|
||||
}
|
||||
ptr=pp;
|
||||
memset(&ptr[m-inc],0,inc);
|
||||
}
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
inline BOOL ajusta_mem()
|
||||
{
|
||||
if(n == m)
|
||||
return TRUE;
|
||||
int oldm = m;
|
||||
m = n;
|
||||
if(m<=0 && ptr)
|
||||
{
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
m =0;
|
||||
return true;
|
||||
}
|
||||
|
||||
T* pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
if(!pp)
|
||||
{
|
||||
m = oldm;
|
||||
return FALSE;
|
||||
}
|
||||
ptr = pp;
|
||||
return TRUE;
|
||||
}
|
||||
//**************************************************************
|
||||
inline BOOL operator+(Cgarray<T> &e) //añade una lista entera
|
||||
{
|
||||
int inc=n+e.n-m;
|
||||
T*pp;
|
||||
if (inc>0)
|
||||
{
|
||||
if (inc<increment)
|
||||
inc=increment;
|
||||
m+=inc;
|
||||
if (ptr)
|
||||
pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
else
|
||||
pp=(T*)malloc(sizeof(T)*m);
|
||||
if (!pp)
|
||||
{
|
||||
m-=inc;
|
||||
return FALSE;
|
||||
}
|
||||
ptr=pp;
|
||||
memset(&ptr[m-inc],0,inc);
|
||||
}
|
||||
memcpy(&ptr[n],e.ptr,e.n*sizeof(T));
|
||||
n+=e.n;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
/*inline BOOL add(Cgarray<T> *e) //añade una lista entera
|
||||
{
|
||||
int inc=n+e->n-m;
|
||||
T*pp;
|
||||
if (inc>0)
|
||||
{
|
||||
if (inc<increment)
|
||||
inc=increment;
|
||||
m+=inc;
|
||||
if (ptr)
|
||||
pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
else
|
||||
pp=(T*)malloc(sizeof(T)*m);
|
||||
if (!pp)
|
||||
{
|
||||
m-=inc;
|
||||
return FALSE;
|
||||
}
|
||||
ptr=pp;
|
||||
memset(&ptr[m-inc],0,inc);
|
||||
}
|
||||
memcpy(&ptr[n],e->ptr,e.n*sizeof(T));
|
||||
n+=e->n;
|
||||
return TRUE ;
|
||||
};*/
|
||||
//**************************************************************
|
||||
inline BOOL add(T *e, int ne) //añade una lista de elementos
|
||||
{
|
||||
int inc=n+ne-m;
|
||||
if (!e || ne<=0)
|
||||
return FALSE;
|
||||
T*pp;
|
||||
if (inc>0)
|
||||
{
|
||||
if (inc<increment)
|
||||
inc=increment;
|
||||
m+=inc;
|
||||
if (ptr)
|
||||
pp=(T*)realloc(ptr,sizeof(T)*m);
|
||||
else
|
||||
pp=(T*)malloc(sizeof(T)*m);
|
||||
if (!pp)
|
||||
{
|
||||
m-=inc;
|
||||
return FALSE;
|
||||
}
|
||||
ptr=pp;
|
||||
memset(&ptr[m-inc],0,inc);
|
||||
}
|
||||
memcpy(&ptr[n],e,ne*sizeof(T));
|
||||
n+=ne;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
inline void borra()//libera la memoria del array
|
||||
{
|
||||
if (ptr)
|
||||
free(ptr);
|
||||
ptr=NULL;
|
||||
m=n=0;
|
||||
}
|
||||
//**************************************************************
|
||||
inline BOOL graba(Cb_file *file)//graba en archivo el array
|
||||
{
|
||||
if(!file->escribe(&n,sizeof(n)))
|
||||
return FALSE;
|
||||
if(!file->escribe(ptr,n*sizeof(T)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
//**************************************************************
|
||||
inline BOOL leer(Cb_file *file)//lee de archivo el array
|
||||
{
|
||||
int nn;
|
||||
if(!file->lee(&nn,sizeof(n)))
|
||||
return FALSE;
|
||||
if( nn<=0 || !((*this)+=nn))
|
||||
return FALSE;
|
||||
if(!file->lee(&ptr[n],nn*sizeof(T)))
|
||||
return FALSE;
|
||||
n+=nn;
|
||||
return TRUE;
|
||||
}
|
||||
//**************************************************************
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
#pragma once
|
||||
#define GARRAY_INCREMENT 100
|
||||
//cola generico---------------------------------
|
||||
//+cosas por le final
|
||||
//-por el inicio
|
||||
template <typename T>
|
||||
struct Element_Cgcola
|
||||
{
|
||||
T t;
|
||||
Element_Cgcola<T> *ant;
|
||||
Element_Cgcola<T> *sig;
|
||||
};
|
||||
template <typename T>
|
||||
class Cgcola
|
||||
{
|
||||
public:
|
||||
//variables----------------------------------------------------------------------------------
|
||||
int n; //numero de elementos en array
|
||||
Element_Cgcola<T> *ini; //inicio del array
|
||||
Element_Cgcola<T> *fin; //fin del array
|
||||
//**************************************************************
|
||||
//constructores-------------------------------------------------------------------------------
|
||||
//**************************************************************
|
||||
Cgcola()
|
||||
{
|
||||
ini=fin=NULL;
|
||||
n=0;
|
||||
};
|
||||
//**************************************************************
|
||||
~Cgcola()
|
||||
{
|
||||
borra();
|
||||
};
|
||||
//**************************************************************
|
||||
//funciones-----------------------------------------------------------------------------------
|
||||
//**************************************************************
|
||||
virtual inline T* operator++()//da puntero al ultimo elemento
|
||||
{
|
||||
if (fin)
|
||||
return &fin->t;
|
||||
return NULL;
|
||||
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline T* operator--()//da puntero al primero
|
||||
{
|
||||
if(ini)
|
||||
return &ini->t;
|
||||
return NULL;
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline BOOL operator+(T &e )//añade al final
|
||||
{
|
||||
if (fin)
|
||||
{
|
||||
fin->sig=(Element_Cgcola<T>*)malloc(sizeof(Element_Cgcola<T>));
|
||||
if (!fin->sig)
|
||||
return FALSE;
|
||||
fin->sig->ant=fin;
|
||||
fin=fin->sig;
|
||||
}
|
||||
else
|
||||
{
|
||||
fin=(Element_Cgcola<T>*)malloc(sizeof(Element_Cgcola<T>));
|
||||
if (!fin)
|
||||
return FALSE;
|
||||
ini=fin;
|
||||
fin->ant=NULL;
|
||||
}
|
||||
fin->t=e;
|
||||
fin->sig=NULL;
|
||||
n++;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline BOOL operator-(T &e) //añade al principio
|
||||
{
|
||||
if (ini)
|
||||
{
|
||||
ini->ant=(Element_Cgcola<T>*)malloc(sizeof(Element_Cgcola<T>));
|
||||
if (!ini->ant)
|
||||
return FALSE;
|
||||
ini->ant->sig=ini;
|
||||
ini=ini->ant;
|
||||
}
|
||||
else
|
||||
{
|
||||
ini=(Element_Cgcola<T>*)malloc(sizeof(Element_Cgcola<T>));
|
||||
if (!ini)
|
||||
return FALSE;
|
||||
fin=ini;
|
||||
ini->sig=NULL;
|
||||
}
|
||||
ini->t=e;
|
||||
ini->ant=NULL;
|
||||
n++;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline BOOL operator+=(T* e )//da el ultimo u lo elimina
|
||||
{
|
||||
if (!fin)
|
||||
return FALSE;
|
||||
*e=fin->t;
|
||||
Element_Cgcola<T> *el=fin;
|
||||
fin=fin->ant;
|
||||
fin->sig=NULL;
|
||||
if (!fin)
|
||||
ini=fin;
|
||||
free(el);
|
||||
n--;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline BOOL operator-=(T* e )//da el primero y lo elimina
|
||||
{
|
||||
if (!ini)
|
||||
return FALSE;
|
||||
*e=ini->t;
|
||||
Element_Cgcola<T> *el=ini;
|
||||
ini=ini->sig;
|
||||
if (!ini)
|
||||
fin=ini;
|
||||
else
|
||||
ini->ant=NULL;
|
||||
free(el);
|
||||
n--;
|
||||
return TRUE ;
|
||||
};
|
||||
//**************************************************************
|
||||
virtual inline void borra()//libera la memoria del array
|
||||
{
|
||||
while(ini)
|
||||
{
|
||||
fin=ini->sig;
|
||||
free(ini);
|
||||
ini=fin;
|
||||
}
|
||||
}
|
||||
//**************************************************************
|
||||
};
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
#pragma once
|
||||
#include "gcola.h"
|
||||
#include "lock.h"
|
||||
//cola concurrente para usar con multiples thread
|
||||
template <typename T>
|
||||
class Cgcola_con :
|
||||
public Cgcola<T>
|
||||
{
|
||||
public:
|
||||
//variables--------------------------------------------------------------------------------
|
||||
Clock cerrojo;//interlock para protejer la cola
|
||||
int modo;//modo 0 bloqueante, modo 1 no bloqueante
|
||||
//funciones--------------------------------------------------------------------------------
|
||||
//*************************************************************************
|
||||
Cgcola_con(void)
|
||||
:Cgcola()
|
||||
{
|
||||
modo=0;
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual ~Cgcola_con(void)
|
||||
{
|
||||
borra();
|
||||
};
|
||||
//*************************************************************************
|
||||
//*************************************************************************
|
||||
virtual inline T* operator++()//da puntero al ultimo elemento
|
||||
{
|
||||
T* res=NULL;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator++();
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual inline T* operator--()//da puntero al primero
|
||||
{
|
||||
T* res=NULL;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator--();
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual inline BOOL operator+(T &e )//añade al final
|
||||
{
|
||||
BOOL res=FALSE;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator+(e);
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual inline BOOL operator-(T &e) //añade al principio
|
||||
{
|
||||
BOOL res=FALSE;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator-(e);
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual inline BOOL operator+=(T* e )//da el ultimo y lo elimina
|
||||
{
|
||||
BOOL res=FALSE;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator+=(e);
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
};
|
||||
//*************************************************************************
|
||||
virtual inline BOOL operator-=(T* e )//da el primero y lo elimina
|
||||
{
|
||||
BOOL res=FALSE;
|
||||
if (modo)
|
||||
{
|
||||
if(!cerrojo.puedo())
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
cerrojo.entro();
|
||||
res= Cgcola::operator-=(e);
|
||||
cerrojo.salgo();
|
||||
return res;
|
||||
};
|
||||
//*************************************************************************
|
||||
};
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
#include "StrArray.h"
|
||||
#include "static_array.h"
|
||||
#define INI_FILE_FLAGS_VACIO 0x0001
|
||||
#define MODULO_INI_FILE "Cini_file"
|
||||
//estructuras necesarias------------------------------------------------------------------
|
||||
typedef struct Ini_file_props
|
||||
{
|
||||
short flags;
|
||||
int p;//propiedad
|
||||
int v;//valor
|
||||
}Ini_file_props;
|
||||
|
||||
typedef struct Ini_file_grupo//cabecera base de la cumunicación
|
||||
{
|
||||
int n; //indice a nombre
|
||||
short flags;
|
||||
Cstatic_array prop;
|
||||
Ini_file_grupo()
|
||||
{
|
||||
inicia();
|
||||
n=0;
|
||||
}
|
||||
void inicia()
|
||||
{
|
||||
prop.n=prop.m=0;
|
||||
prop.buf=NULL;
|
||||
prop.z=sizeof(Ini_file_props);
|
||||
prop.incremento=100;
|
||||
}
|
||||
Ini_file_props* get(int i)//da la propiedad i
|
||||
{
|
||||
return (Ini_file_props*) prop.get(i);
|
||||
}
|
||||
Ini_file_props* set_coun()//reserva para una propiedad mas y da el puntero
|
||||
{
|
||||
prop.reserva();
|
||||
prop.n++;
|
||||
return (Ini_file_props*) &prop.buf[prop.z*(prop.n-1)];
|
||||
}
|
||||
}Ini_file_grupo;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
class C_error;
|
||||
class UTILES_EXPORT Cini_file
|
||||
{
|
||||
//variables--------------------------
|
||||
private:
|
||||
StrArray str;
|
||||
Cstatic_array grupos;
|
||||
BOOL borra_error;
|
||||
public:
|
||||
C_error *er;
|
||||
|
||||
Cini_file(C_error* err=NULL);
|
||||
~Cini_file(void);
|
||||
//funciones--------------------------
|
||||
BOOL lee(char *path_);//lee archivo ini y lo carga en memoria
|
||||
|
||||
|
||||
int get_grupo(char* gr);
|
||||
int geti_valor(int gr,char *pro);//devuelve el indice del str valor
|
||||
|
||||
//funciones que dan el valor--------------
|
||||
char* get(int gr,char *pro);// valor en forma de char*
|
||||
int get(int gr,char *pro, int def);
|
||||
double get(int gr,char *pro, double def);
|
||||
char* get( int gr,char *pro, char *def);
|
||||
void dame_valor( int gr,char *pro, char* dst,char *def);
|
||||
//funciones de escritura-----------------
|
||||
void borra();
|
||||
BOOL guarda(char *path);//guarda ini cargado en memoria en un archivo;
|
||||
int add_grupo(char *gr);//añade un grupo nuevo y da el indice
|
||||
int add(int gr,char *pro,char *val);//añade valor de propiedad
|
||||
|
||||
//sobrecarga escritura-----------------
|
||||
int add(int gr,char *pro,int val);//añade valor de propiedad
|
||||
int add(int gr,char *pro,double val);//añade valor de propiedad
|
||||
//funciones aux------------------------
|
||||
private:
|
||||
//funciones ayuda para leer
|
||||
char* busca(char *st,char c);//busca en str el char c o el nulo
|
||||
char* buscamos_grupo(char *st);//busca el siguiente grupo en str
|
||||
char* busca_prop(char* st);
|
||||
Ini_file_grupo* set_coun();
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
|
||||
#define CLOCK_ESTADO_BLOQUEADO 1
|
||||
#define CLOCK_ESTADO_DESBLOQUEADO 0
|
||||
|
||||
class UTILES_EXPORT Clock//estructura para concurrencia
|
||||
{
|
||||
public:
|
||||
|
||||
long t_sleep;//tiempo de sleep en milisegundos
|
||||
|
||||
Clock(void);
|
||||
~Clock(void);
|
||||
|
||||
void entro();//pilla el cerrojo durmiendo si es necesario
|
||||
void salgo();//libera el cerrojo
|
||||
BOOL puedo();//intenta pillar el cerrojo, si ya estaba pillado devuelve false si no true
|
||||
|
||||
private:
|
||||
long volatile cerrojo;//variable volatile
|
||||
long cliente;//id del thred que tiene el cerrojo
|
||||
CRITICAL_SECTION cerrojo1;
|
||||
int modo;//indica si usa cerrojo 0 o 1
|
||||
|
||||
|
||||
|
||||
};
|
||||
UTILES_EXPORT long lck_sum_atm(long *n,int i);//suma de manera atomica i a n
|
||||
|
|
@ -0,0 +1,354 @@
|
|||
#pragma once
|
||||
#ifndef CmapMat_H
|
||||
#define CmapMat_H
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#define VALNOEXIST_FLOAT (float) 1.e+30
|
||||
#define VALNOEXIST_INT (int) -1
|
||||
#include "garray.h"
|
||||
#include "th.h"
|
||||
|
||||
#pragma pack(8)
|
||||
typedef struct HeadCostConj
|
||||
{
|
||||
int ver; //versión
|
||||
bool isVect; // vect o map
|
||||
int n; //num de elems guardados
|
||||
}HeadCostConj;
|
||||
typedef struct HeadCostAng
|
||||
{
|
||||
int ver; //versión
|
||||
int n; //num de elems guardados
|
||||
}HeadCostAng;
|
||||
#pragma pack (1)
|
||||
typedef struct MapDataFloat{
|
||||
int k;
|
||||
float v;
|
||||
}MapDataFloat;
|
||||
typedef struct MapDataInt{
|
||||
int k;
|
||||
int v;
|
||||
}MapDataInt;
|
||||
#pragma pack(16)
|
||||
#define MAX_THREAD_LEE 8
|
||||
//matixFloat---------------------------------------------
|
||||
class UTILES_EXPORT CmapRowFloat
|
||||
{
|
||||
|
||||
public:
|
||||
//*********************************
|
||||
//Variables
|
||||
bool isVect;
|
||||
int imin, imax;
|
||||
std::map<int, float> dat;
|
||||
std::vector<float> datv;
|
||||
//*********************************
|
||||
//Métodos
|
||||
CmapRowFloat()
|
||||
{
|
||||
isVect = false;
|
||||
imin=INT_MAX;
|
||||
imax=INT_MIN;
|
||||
}
|
||||
~CmapRowFloat(void)
|
||||
{
|
||||
}
|
||||
//******************************************************
|
||||
inline void set(int i, float v)
|
||||
{
|
||||
|
||||
|
||||
if(isVect)
|
||||
datv[i]=v;
|
||||
else
|
||||
{
|
||||
if(v== VALNOEXIST_FLOAT)
|
||||
return;
|
||||
dat[i] = v;
|
||||
if(i<imin)
|
||||
imin=i;
|
||||
if(i>imax)
|
||||
imax=i;
|
||||
}
|
||||
}
|
||||
//******************************************************
|
||||
inline float operator[](int irow)
|
||||
{
|
||||
if(isVect)
|
||||
return datv[irow];
|
||||
if(irow< imin || irow>imax)
|
||||
return VALNOEXIST_FLOAT;
|
||||
//si tiene esa clave la devuelve, si no, devuelve MAYUSCULO
|
||||
std::map<int, float>::iterator elem = dat.find(irow);
|
||||
if(elem == dat.end())
|
||||
//no tiene la clave
|
||||
return VALNOEXIST_FLOAT;
|
||||
return elem->second;
|
||||
}
|
||||
inline void configVector(int ymax)
|
||||
{
|
||||
isVect = true;
|
||||
dat.clear();
|
||||
|
||||
//datv.reserve(ymax);
|
||||
datv.insert(datv.begin(),ymax,VALNOEXIST_FLOAT);
|
||||
|
||||
bool inVector = false;
|
||||
/*for (int i =0 ; i<ymax; i++)
|
||||
datv.push_back(VALNOEXIST_FLOAT);*/
|
||||
}
|
||||
//ajusta map a memoria justa
|
||||
inline void memAjust()
|
||||
{
|
||||
|
||||
}
|
||||
inline void clear()
|
||||
{
|
||||
dat.clear();
|
||||
datv.clear();
|
||||
isVect=false;
|
||||
}
|
||||
|
||||
BOOL guarda(HeadCostConj hd, int ic, char *path , char *ext, Cgarray<MapDataFloat> *bufer = NULL);
|
||||
BOOL lee(int ic, char *path , char *ext, int ntot, BOOL mismosvect=TRUE, Cgarray<MapDataFloat> *bufer = NULL);
|
||||
};
|
||||
#define MAX_MEM_MAPFLOAT 1024.*1024.*300./sizeof(float)
|
||||
|
||||
class UTILES_EXPORT CmapMatFloat
|
||||
{
|
||||
public:
|
||||
//*********************************
|
||||
//Variables
|
||||
std::vector<CmapRowFloat> dat;
|
||||
|
||||
//*********************************
|
||||
//Métodos
|
||||
CmapMatFloat()
|
||||
{
|
||||
}
|
||||
~CmapMatFloat(void)
|
||||
{
|
||||
}
|
||||
//******************************************************
|
||||
inline CmapRowFloat& operator[](int irow)
|
||||
{
|
||||
return dat[irow];
|
||||
}
|
||||
|
||||
inline void set(int x, int y, float val)
|
||||
{
|
||||
if(val>= VALNOEXIST_FLOAT)
|
||||
return;
|
||||
|
||||
dat[x].set(y,val);
|
||||
}
|
||||
//ajusta los map a la memoria minima posible
|
||||
inline void memAjust()
|
||||
{
|
||||
for(std::vector<CmapRowFloat>::iterator elem = dat.begin(); elem!= dat.end(); elem++)
|
||||
{
|
||||
elem->memAjust();
|
||||
}
|
||||
}
|
||||
inline void clear()
|
||||
{
|
||||
dat.clear();
|
||||
}
|
||||
|
||||
//reparte los nvect disponibles entre los threads, poniendo las primeras filas de cada uno de vect
|
||||
inline void inicializa(int xmax, int nthr, int nvect=-1)
|
||||
{
|
||||
dat.reserve(xmax);
|
||||
bool inVector = false;
|
||||
if(nvect<0)
|
||||
nvect =(int)(MAX_MEM_MAPFLOAT/xmax);
|
||||
|
||||
int vectthr=0,novecthr=0,iparc=0;
|
||||
if(nvect<xmax)
|
||||
{
|
||||
vectthr = (int)(nvect*1./nthr);
|
||||
novecthr = (int)((xmax-nvect)*1./nthr);
|
||||
}
|
||||
//xmax = novec;
|
||||
for (int i =0 ; i<xmax; i++)
|
||||
{
|
||||
dat.push_back(CmapRowFloat());
|
||||
if(nvect>=xmax)
|
||||
dat[i].configVector(xmax);
|
||||
else if(nvect>0)
|
||||
{
|
||||
if((i-iparc)<vectthr)
|
||||
dat[i].configVector(xmax);
|
||||
else if((i-iparc)>=(vectthr+novecthr))
|
||||
iparc+=vectthr+novecthr;
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOL lee(char *path, char *ext, BOOL mismosvect=TRUE);
|
||||
BOOL leeThread( char *path, char *ext, int nthread, BOOL mismosvect/*=TRUE*/);
|
||||
};
|
||||
class UTILES_EXPORT ThMapMatFloatLee: public Cth
|
||||
{
|
||||
public:
|
||||
CmapMatFloat *pclas;
|
||||
int ini;//fila inicio
|
||||
int fin;//fila fin
|
||||
int ithr;
|
||||
BOOL mal;//indica si ha ido bien
|
||||
BOOL mismosvect;
|
||||
char*path;
|
||||
char*ext;
|
||||
virtual void run();
|
||||
};
|
||||
class UTILES_EXPORT CmapRowInt
|
||||
{
|
||||
public:
|
||||
//*********************************
|
||||
//Variables
|
||||
std::map<int, int> dat;
|
||||
std::vector<int> datv;
|
||||
int imin, imax;
|
||||
bool isVect;
|
||||
//*********************************
|
||||
//Métodos
|
||||
CmapRowInt()
|
||||
{
|
||||
imin=INT_MAX;
|
||||
imax=INT_MIN;
|
||||
isVect = false;
|
||||
}
|
||||
~CmapRowInt(void)
|
||||
{
|
||||
}
|
||||
//******************************************************
|
||||
inline void set(int i, int v)
|
||||
{
|
||||
if(v== VALNOEXIST_INT)
|
||||
return;
|
||||
|
||||
if(isVect)
|
||||
datv[i]=v;
|
||||
else
|
||||
dat[i] = v;
|
||||
|
||||
if(i<imin)
|
||||
imin=i;
|
||||
if(i>imax)
|
||||
imax=i;
|
||||
}
|
||||
//******************************************************
|
||||
inline int operator[](int irow)
|
||||
{
|
||||
if(isVect)
|
||||
return datv[irow];
|
||||
if(irow< imin || irow>imax)
|
||||
return -1;
|
||||
|
||||
//si tiene esa clave la devuelve, si no, devuelve MAYUSCULO
|
||||
std::map<int, int>::iterator elem = dat.find(irow);
|
||||
if(elem == dat.end())
|
||||
//no tiene la clave
|
||||
return VALNOEXIST_INT;
|
||||
return elem->second;
|
||||
}
|
||||
//ajusta map a memoria justa
|
||||
inline void memAjust()
|
||||
{
|
||||
|
||||
}
|
||||
inline void configVector(int ymax)
|
||||
{
|
||||
isVect = true;
|
||||
dat.clear();
|
||||
datv.insert(datv.begin(),ymax,VALNOEXIST_INT);
|
||||
/*datv.reserve(ymax);
|
||||
for (int i =0 ; i<ymax; i++)
|
||||
datv.push_back(VALNOEXIST_INT);*/
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
isVect = false;
|
||||
dat.clear();
|
||||
datv.clear();
|
||||
}
|
||||
BOOL guarda(HeadCostConj hd, int ic, char *path , char *ext);
|
||||
BOOL lee(int ic, char *path, char *ext, BOOL mismosvect=TRUE );
|
||||
};
|
||||
#define MAX_MEM_MAPINT 1024.*1024.*200./sizeof(int)
|
||||
class UTILES_EXPORT CmapMatInt
|
||||
{
|
||||
public:
|
||||
//*********************************
|
||||
//Variables
|
||||
std::vector<CmapRowInt> dat;
|
||||
|
||||
//*********************************
|
||||
//Métodos
|
||||
CmapMatInt()
|
||||
{
|
||||
}
|
||||
~CmapMatInt(void)
|
||||
{
|
||||
}
|
||||
//******************************************************
|
||||
inline CmapRowInt& operator[](int irow)
|
||||
{
|
||||
return dat[irow];
|
||||
}
|
||||
|
||||
inline void set(int x, int y, int val)
|
||||
{
|
||||
if(val== VALNOEXIST_INT)
|
||||
return;
|
||||
dat[x].set(y,val);
|
||||
}
|
||||
//ajusta los map a la memoria minima posible
|
||||
inline void memAjust()
|
||||
{
|
||||
for(std::vector<CmapRowInt>::iterator elem = dat.begin(); elem!= dat.end(); elem++)
|
||||
{
|
||||
elem->memAjust();
|
||||
}
|
||||
}
|
||||
inline void clear()
|
||||
{
|
||||
dat.clear();
|
||||
}
|
||||
|
||||
inline void inicializa(int xmax, int nthr, int nvect=-1)
|
||||
{
|
||||
dat.reserve(xmax);
|
||||
bool inVector = false;
|
||||
if(nthr<=0)
|
||||
nthr=1;
|
||||
if(nvect<0)
|
||||
nvect =(int)(MAX_MEM_MAPINT/xmax);
|
||||
int vectthr=0,novecthr=0,iparc=0;
|
||||
if(nvect<xmax)
|
||||
{
|
||||
vectthr = (int)(nvect*1./nthr);
|
||||
novecthr = (int)((xmax-nvect)*1./nthr);
|
||||
}
|
||||
|
||||
for (int i =0 ; i<xmax; i++)
|
||||
{
|
||||
dat.push_back(CmapRowInt());
|
||||
if(nvect>=xmax)//nvec>=xmax
|
||||
dat[i].configVector(xmax);
|
||||
else if(nvect==0)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
if((i-iparc)<vectthr)
|
||||
dat[i].configVector(xmax);
|
||||
else if((i-iparc)>=(vectthr+novecthr))
|
||||
iparc+=vectthr+novecthr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
#include "_proceso.h"
|
||||
#include "base_head.h"
|
||||
class Csock_sv;
|
||||
class UTILES_EXPORT Cproceso_cliente: public C_proceso
|
||||
{
|
||||
public:
|
||||
Csock_sv *soc;
|
||||
Cproceso_cliente(void);
|
||||
~Cproceso_cliente(void);
|
||||
//virtual void run(){};
|
||||
};
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#include "Csock_cl.h"
|
||||
#include "th.h"
|
||||
#include <afxwin.h>
|
||||
class Cproceso_cliente;
|
||||
class UTILES_EXPORT Cescucha_sock_sv//interface para que te entren los accept
|
||||
{
|
||||
public:
|
||||
virtual Cproceso_cliente* crea_cliente(BOOL *pirate)=0;//funcion que crea los procesos cliente en el accept (devuelve null si no se acepta)
|
||||
};
|
||||
//socket generico si se pone una escucha crea los socket cliente desde la escucha
|
||||
//si no desde la funcion crea_cliente
|
||||
//si el proceso cliente ya tiene un socket creado no se crea si no se crea un socket cliente
|
||||
class UTILES_EXPORT Csock_sv : public Csock_cl
|
||||
{
|
||||
public:
|
||||
BOOL sock_cerrado;
|
||||
Cescucha_sock_sv *escucha;
|
||||
Csock_sv(BOOL* sal=NULL, C_error*e=NULL);
|
||||
virtual ~Csock_sv(void);
|
||||
Cproceso_cliente* (*crea_cliente)(BOOL *pirate );
|
||||
//funciones servidor------------------------------------
|
||||
virtual void OnAccept(int nErrorCode);
|
||||
virtual void OnClose(int nErrorCode);
|
||||
//virtual void run();
|
||||
//funciones virtuales de thread win
|
||||
};
|
||||
//socket servidor con thread y cola de evntos propia
|
||||
|
||||
class UTILES_EXPORT Csock_svThread :public CWinThread
|
||||
{
|
||||
//DECLARE_DYNCREATE(Csock_svThread)
|
||||
BOOL isLisening;
|
||||
BOOL pireateTread;
|
||||
int port, type, evenFlag;
|
||||
char * url;
|
||||
|
||||
public:
|
||||
Cescucha_sock_sv *escucha;
|
||||
Cproceso_cliente* (*crea_cliente)(BOOL *pirate );
|
||||
BOOL liseningThread(int port, char * url, int type = SOCK_STREAM, int evenFlag = FD_ACCEPT | FD_READ | FD_CLOSE );//inicia escucha
|
||||
void close();//cierra escucha
|
||||
//funciones aux------------------------
|
||||
~Csock_svThread();
|
||||
Csock_svThread();
|
||||
//AfxSocketInit()
|
||||
virtual BOOL InitInstance() ;
|
||||
virtual int Run() ;
|
||||
CString sName ;//nombre thread
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
class UTILES_EXPORT Cstatic_array
|
||||
{
|
||||
public:
|
||||
int z;//tamaño de la memoria
|
||||
int n;//capacidad usada de la memoria
|
||||
int m;//capacidad total de la memoria
|
||||
int incremento;
|
||||
BYTE* buf;
|
||||
Cstatic_array(int size=1);
|
||||
~Cstatic_array(void);
|
||||
//funciones---------------------------------------
|
||||
BYTE* get(int i);//da el elemento i
|
||||
BYTE* get_cp(int i);//da una copia del elemento i
|
||||
void add(BYTE* e);//añade elemento
|
||||
void borra();//borra elementos
|
||||
//funciones aux----------------------------------
|
||||
BOOL reserva(int p=1);//reserva memoria para p posiciones mas
|
||||
};
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006-2008 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||
#ifndef _W64
|
||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
# else
|
||||
# define _W64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
|
||||
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
// realize that, e.g. char has the same size as __int8
|
||||
// so we give up on __intX for them.
|
||||
#if (_MSC_VER < 1300)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#else
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef signed __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef _W64 signed int intptr_t;
|
||||
typedef _W64 unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
#pragma once
|
||||
#include <afxsock.h>
|
||||
#include "base_head.h"
|
||||
#define MAX_CHAR_BLOQ_STRSOCKET 1024 //Maximo de caracteres por envio
|
||||
#include "_error.h"
|
||||
|
||||
#define ESPERA_STRSOCKET 1 //milis en sleep
|
||||
#define ESPERA_SEG_STRSOCKET 3//SEGUNDOS MAXIMOS INTENTANDO RECIBIR ENVITOS
|
||||
#define VECES_ESPERA_STRSOCKET ((1000 * ESPERA_SEG_STRSOCKET) / ESPERA_STRSOCKET)
|
||||
#define MIN_REALLOC_STR_SOC 512 //bytes
|
||||
/*
|
||||
Socket cliente para envio de informacion ascii (string)
|
||||
*/
|
||||
class UTILES_EXPORT Cstr_socket : public CAsyncSocket
|
||||
{
|
||||
public:
|
||||
//variables--------------------------------------
|
||||
C_error er;//variable que da info de posibles errores
|
||||
BOOL pirate;//==TRUE -> se cancela todas las tareas del socket
|
||||
long cli_currando;//indica que el socket esta en uso
|
||||
Cstr_socket *pp; //puntero al padre
|
||||
//variables aux----------------------------------
|
||||
private:
|
||||
char *buf;//buffer de envios
|
||||
int n, m;//ocupacion y capacidad del buffer
|
||||
int nb;//indica el numero de bytes que va por envio total
|
||||
|
||||
public:
|
||||
//c y d------------------------------------------
|
||||
Cstr_socket(void);
|
||||
~Cstr_socket(void);
|
||||
public:
|
||||
//funciones--------------------------------------
|
||||
BOOL crear(char *ip=NULL, int puerto=0);//crea el socket en la ip y puerto de salida indicados
|
||||
BOOL conecta(char *ip, int puerto);//contecta a servidor
|
||||
char* recibir();//recibe string;
|
||||
BOOL envia( char *fmt, ...);//envia string
|
||||
void cierra();//cierra socket
|
||||
char *getbuf();//devuelve buffer del socket
|
||||
//funciones auxiliares---------------------------
|
||||
private:
|
||||
BOOL cuida_mem(int nbb);//pide memoria si hace falta
|
||||
int recibir(BYTE *b, int nbb);//recive nbb bytes y los deja en b
|
||||
BOOL enviar(int nbb,BYTE *b);
|
||||
|
||||
};
|
||||
/*
|
||||
Socket servidor para envio de informacion ascii (string)
|
||||
*/
|
||||
class UTILES_EXPORT Cstr_socket_srv : public Cstr_socket
|
||||
{
|
||||
//variables aux----------------------------------
|
||||
private:
|
||||
HWND wnd;//ventana a la que mandar eventos
|
||||
int id_even, id_comman;
|
||||
BOOL *sal_soc;
|
||||
int t_out;//tiempo de salida sin hacer nada
|
||||
__int64 t;
|
||||
public:
|
||||
//c y d------------------------------------------
|
||||
Cstr_socket_srv(void);
|
||||
~Cstr_socket_srv(void);
|
||||
//funciones--------------------------------------
|
||||
virtual BOOL on_datos_recibidos(char *txt)=0;//funcion donde procesar los datos
|
||||
virtual Cstr_socket_srv* crea_cliente()=0;//funcion donde procesar los datos
|
||||
|
||||
BOOL pon_escucha(char *ip, int puerto);
|
||||
void pon_wnd_destruc(HWND wnd,int id_comman,int id_even);
|
||||
//funciones auxiliares---------------------------
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
void run();
|
||||
virtual void OnAccept(int nErrorCode);
|
||||
virtual void OnClose(int nErrorCode);
|
||||
static UINT th_funcion(LPVOID pp);
|
||||
void pon_tout( int t_out );
|
||||
};
|
||||
//funciones de socket cliente para pinvoke-----------------------------------------------------
|
||||
extern "C" UTILES_EXPORT Cstr_socket *str_socket_crea();
|
||||
extern "C" UTILES_EXPORT BOOL str_socket_conecta(Cstr_socket *soc, char *ip, int puerto);
|
||||
extern "C" UTILES_EXPORT BOOL str_socket_envia(Cstr_socket *soc, char *txt);
|
||||
extern "C" UTILES_EXPORT int str_socket_recive(Cstr_socket* soc);
|
||||
extern "C" UTILES_EXPORT void str_socket_dame_buf(Cstr_socket* soc, char* buf);
|
||||
extern "C" UTILES_EXPORT void str_socket_dame_error(Cstr_socket* soc, char* error);
|
||||
extern "C" UTILES_EXPORT void str_socket_borra(Cstr_socket* soc);
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
#ifndef INCLUDE_TH_UTILES
|
||||
#define INCLUDE_TH_UTILES
|
||||
|
||||
#include "base_head.h"
|
||||
const DWORD MS_VC_EXCEPTION_TH_UTILES=0x406D1388;
|
||||
//funciones necesarias-------------
|
||||
UTILES_EXPORT void SetThName( DWORD dwThreadID, char* threadName);
|
||||
UINT main_th_proceso(LPVOID pp);
|
||||
//thead basico---------------------
|
||||
class UTILES_EXPORT Cth
|
||||
{
|
||||
|
||||
public:
|
||||
bool running;//variable interna no usar
|
||||
//variables
|
||||
|
||||
char nombre[32];//nombre del thread
|
||||
CWinThread * m_thread;//puntero a thread
|
||||
//cosntructor y destructor---------------
|
||||
Cth(void);
|
||||
~Cth(void);
|
||||
//funicones------------------------------
|
||||
virtual void run()=0;//funcion que hace el thread
|
||||
bool isRunning();//indica si se esta currando o no
|
||||
|
||||
BOOL lanza(char *nombre=NULL);//lanzar thread
|
||||
|
||||
//********************************
|
||||
void join();//espera a que el thread termine
|
||||
};
|
||||
|
||||
class UTILES_EXPORT Crunable
|
||||
{
|
||||
public:
|
||||
virtual void frun(int modo=0)=0;
|
||||
};
|
||||
#endif
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
#pragma once
|
||||
#include "th.h"
|
||||
#include "gcola_con.h"
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct Timers_Cth_cola
|
||||
{
|
||||
T tarea;//tarea a encadenar
|
||||
__int64 t;//tiempo desde la ultima ejecucion
|
||||
int dt;//periodo del timer
|
||||
};
|
||||
//------------------------------------------------------------
|
||||
class Cth_rimers_cola : //tread para los timers
|
||||
public Cth
|
||||
{
|
||||
public:
|
||||
Crunable *clase_run;
|
||||
inline virtual void run()
|
||||
{
|
||||
clase_run->frun(0);
|
||||
}
|
||||
};
|
||||
//cola asincrona--------------------------------------------
|
||||
//thread de tareas tipico-----------------------------------
|
||||
template <typename T>
|
||||
class Cth_cola : //falta probar, poner timers
|
||||
public Cth, Crunable
|
||||
{
|
||||
public:
|
||||
Cgcola_con<T> cola;//cola de tareas pendientes
|
||||
Cgcola_con<Timers_Cth_cola<T>> timers;//tareas periodicas activas
|
||||
BOOL pirate;//indica al tread que hay que terminar
|
||||
BOOL eje_fin;//indica que hay que ejecutar la tarea final
|
||||
int time_sleep;//tiempo de espera cuando no hay tareas
|
||||
int tp_max;//maximo de tareas pendientes en cola
|
||||
T tfin;//tarea final;
|
||||
Cth_rimers_cola thtimers;//thread de control de tareas periodicas
|
||||
//constructor y destructor--------------------------------
|
||||
//**************************************************
|
||||
Cth_cola(void)
|
||||
{
|
||||
pirate=FALSE;
|
||||
time_sleep=1;
|
||||
tp_max=1000;
|
||||
eje_fin=FALSE;
|
||||
thtimers.clase_run=this;
|
||||
thtimers.join();
|
||||
|
||||
|
||||
};
|
||||
//**************************************************
|
||||
~Cth_cola(void)
|
||||
{
|
||||
fin();
|
||||
};
|
||||
//funciones-----------------------------------------------
|
||||
void pon_tfin(T &e)
|
||||
{
|
||||
tfin=e;
|
||||
eje_fin=TRUE;
|
||||
};
|
||||
//**************************************************
|
||||
virtual inline BOOL operator+(T &e )//añade tarea
|
||||
{
|
||||
return !pirate && cola.n<=tp_max && cola+e;
|
||||
};
|
||||
//**************************************************
|
||||
virtual inline BOOL operator-(T &e )//añade tarea y elimina el resto
|
||||
{
|
||||
if (pirate)
|
||||
return FALSE;
|
||||
cola.cerrojo.entro();
|
||||
cola.borra();
|
||||
cola.cerrojo.salgo();
|
||||
return cola+e;
|
||||
};
|
||||
//**************************************************
|
||||
virtual void fin()//termina el proceso
|
||||
{
|
||||
pirate=TRUE;
|
||||
thtimers.join();
|
||||
join();
|
||||
|
||||
};
|
||||
//**************************************************
|
||||
BOOL pon_timer(int seg, T &tar)//pone una tarea periodica siendo t el periodo en seg
|
||||
{
|
||||
Timers_Cth_cola<T> tim;
|
||||
tim.t=0;
|
||||
tim.tarea=tar;
|
||||
tim.dt=seg;
|
||||
timers+tim;
|
||||
return TRUE;
|
||||
};
|
||||
//**************************************************
|
||||
virtual void procesa(T &t)//override de procesado que hay que sobreescribir
|
||||
{
|
||||
|
||||
};
|
||||
//**************************************************
|
||||
virtual void run()//proceso que despacha
|
||||
{
|
||||
T tarea;
|
||||
sprintf(thtimers.nombre,"%s_timers",nombre);
|
||||
if (timers.n)
|
||||
thtimers.lanza();
|
||||
while (!pirate)
|
||||
{
|
||||
if (cola-=&tarea)
|
||||
procesa(tarea);
|
||||
else
|
||||
Sleep(time_sleep);
|
||||
}
|
||||
if(eje_fin)
|
||||
procesa(tfin);
|
||||
};
|
||||
//**************************************************
|
||||
virtual void frun(int modo=0)//proceso del timer
|
||||
{
|
||||
__int64 t;
|
||||
Element_Cgcola<Timers_Cth_cola<T>> *e;
|
||||
while(!pirate)
|
||||
{
|
||||
timers.cerrojo.entro();
|
||||
e=timers.ini;
|
||||
t=_time64(NULL);
|
||||
while(e)
|
||||
{
|
||||
if (e->t.t<t)
|
||||
{
|
||||
if(Cth_cola::operator+(e->t.tarea))
|
||||
e->t.t=t+e->t.dt;
|
||||
}
|
||||
e=e->sig;
|
||||
}
|
||||
Sleep(500);
|
||||
}
|
||||
};
|
||||
//**************************************************
|
||||
};
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
#pragma once
|
||||
//defines de carpetas-----------------------------------------------------------------------
|
||||
|
||||
#define D_WORK "%dir_work%"
|
||||
#define D_LOG "%dir_log%"
|
||||
#define D_APP "%dir_exe%"
|
||||
#define D_DAT "%dir_dat%"
|
||||
#define P_CONG "%p_config%"
|
||||
|
||||
//define para comunicacion------------------------------------------------------------------
|
||||
#define VERSION_PACKAGE_HEAD 1 //version de metodo de comunicacion
|
||||
#define MAX_LONG_PACKAGE_0 0x04000 //maximo de bytes por package
|
||||
//flags de cabecera
|
||||
|
||||
/*
|
||||
#define FLAG_PACKAGE_HEAD_0_INICIO 0x00000001
|
||||
#define FLAG_PACKAGE_HEAD_0_CONTINUACION 0x00000002
|
||||
#define FLAG_PACKAGE_HEAD_0_FINAL 0x00000004*/
|
||||
|
||||
#define FLAG_PACKAGE_HEAD_0_ENCRIPT1 0x00000001
|
||||
#define FLAG_PACKAGE_HEAD_0_REPLICADO 0x00000002
|
||||
//estructuras para comunicacion-------------------------------------------------------------
|
||||
typedef struct Package_head_0//cabecera base de la cumunicación
|
||||
{
|
||||
int version; //version de comunicacion
|
||||
int flags; //flags
|
||||
int nb; //numero de bytes del paquete
|
||||
int n; //numero de bloques de este paquete
|
||||
}Package_head_0;
|
||||
//en esta version el identificador de los paquetes sera un entero (int)
|
||||
//paquetes generales de envio----------------------------------------------------------------
|
||||
#define PETICION_GENERAL_NO 0//paquete de negacion
|
||||
|
||||
#define PETICION_GENERAL_PRESENTA 1//peticion de presentacion usuario y key
|
||||
#define PETICION_GENERAL_OK 2//respuesta ok automatica
|
||||
#define PETICION_GENERAL_DESCONECTA 3//peticion de desconexion
|
||||
#define PETICION_GENERAL_DAME_LOG 4//peticion de eventos (normalmente con id)
|
||||
#define PETICION_GENERAL_TOMA_COMANDO 5//peticionde comando para servidor
|
||||
#define PETICION_GENERAL_FIN 6
|
||||
|
||||
|
||||
//define para usuarios------------------------------------------------------------------------
|
||||
#define VERSION_USUARIO_CONEXION 1 //version de usuarios
|
||||
//flags usuarios
|
||||
#define FLAG_USUARIO_CONEXION_INDI 0x00000001//indica que solo se acepta una conexion por dicho usuario
|
||||
#define FLAG_USUARIO_CONEXION_EN_USO 0x00000002//indica que el usuario esta en uso actualmente
|
||||
#define FLAG_USUARIO_CONEXION_VACIO 0x00000004//indica que el usuario esta borrado
|
||||
#define FLAG_USUARIO_CONEXION_BLOQ 0x00000008//indica que el usuario esta bloqueado (no se puede usar)
|
||||
//flags archivo
|
||||
#define FLAG_FILE_USUARIO_CONEX_ENCRIP 0x00000001//indica que el archivo esta encriptado
|
||||
//flags permisos
|
||||
|
||||
//estructura para usuarios---------------------------------------------------------------------
|
||||
typedef struct Usuario_conx_0//informacion de usuario
|
||||
{
|
||||
int flags;
|
||||
int id; //identificador de usuario
|
||||
int permisos; //flags de permisos
|
||||
int ia; //informacion adicional
|
||||
int ncon; //numero de conectados con este usuario
|
||||
char nombre[32]; //nombre de usuario
|
||||
char clave[32]; //calve de usuario
|
||||
}Usuario_conx_0;
|
||||
|
||||
typedef struct Head_usuario_conex_0//cabecera de archivo de usuario
|
||||
{
|
||||
int version; //version informacion de usuaros
|
||||
int flags; //flags
|
||||
int n; //numero de usuarios en archivo
|
||||
}Head_usuario_conex_0;
|
||||
|
||||
//interface de elemento que se transfiere----------------------------------
|
||||
class IdataTransfer
|
||||
{
|
||||
public:
|
||||
//para lectura
|
||||
virtual __int64 getNB_it()=0;//devuelve numero de bites totales de informacion
|
||||
virtual __int64 getNext_it(void* buf,__int64 nb)=0;//copia en buffer buf el los siguientes nb bytes y devuelve el numero total de bites leidos
|
||||
|
||||
//lectura y escritura
|
||||
inline virtual bool setPosition_it(__int64 nb){ return false; };//se posiciona en el byte nb los datos
|
||||
|
||||
//para escritura-----------
|
||||
inline virtual bool set_it(void* buf, __int64 nb){ return true; };//prepara datos para recivir nb bites
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include "base_head.h"
|
||||
class StrArray;
|
||||
class UTILES_EXPORT Cutl
|
||||
{
|
||||
public:
|
||||
Cutl(void);
|
||||
~Cutl(void);
|
||||
//cifra y descifra datos con FLAG_PACKAGE_HEAD_0_ENCRIPT1
|
||||
static void cifra1(BYTE*b,int nb);
|
||||
static void cifra1(char*b);//ojo con los char despues de cifrar no usar stlen ni semejantes
|
||||
static void descifra1(char*b);
|
||||
static void descifra1(BYTE* b,int nb);
|
||||
//--------------------------------------------------------
|
||||
static void big_little(BYTE* b,int nb);//cambia de little a big_endian y viceversa
|
||||
//ordenacion----------------------------------------------
|
||||
static int busca(BYTE*lista,int n,int sizeElement,BYTE *e, int (*funcion)(BYTE*,BYTE*) );//busqueda dicotomica
|
||||
static StrArray* stringSplit(char *orig,char* subStr, StrArray*buf);
|
||||
|
||||
//identificador pc----------------------------------------
|
||||
static char* id_pc(char*idm, int nb);//proporciona un identificador unico de la computadora
|
||||
static DWORDLONG getMemoDisp();//devuelve la memoria disponible
|
||||
static DWORDLONG getMemoDisp1Malloc();//devuelve la memoria disponible real en mem1 en un malloc
|
||||
|
||||
//identificacion de usuario de windows--------------------
|
||||
static char* getWinUser(char* buf);//leng de 256
|
||||
|
||||
//funciones de string--------------------------------
|
||||
static int str_hex2int(char* st);//pasa de cadena de caracteres tipo 0xff a entero
|
||||
static void int2str_hex( char* st , int n);
|
||||
|
||||
static bool lanza_exe(char *appName, char *comline, DWORD *processId = NULL);//ejecuta appName
|
||||
};
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue