// may be constructed only by derived classes DXFEntity::DXFEntity(DXFEntities *e, String const &k) { entities = e; kind = k; color = e->GetCurrentColor(); lineType = e->GetCurrentLineType(); layer = e->GetCurrentLayer(); handle = GetNextHandle(); }
/*---------------------------------------------------------------------*/ H_ARCHIVE ArchiveOpenForWrite(CHAR * path) { H_ARCHIVE harchive; ARCHIVE *archive; ArchiveLog(ARC_LOG_VERBOSE, "Open archive for write: %s", path); _archive_error = ARC_NO_ERROR; /* Get next available handle */ if ((harchive = GetNextHandle()) == VOID_H_ARCHIVE) return (VOID_H_ARCHIVE); _archive[harchive].last_error = ARC_NO_ERROR; /* Check out the path */ if (!ValidatePath(path, harchive)) return (VOID_H_ARCHIVE); /* Create stream list */ if (!CreateList(&_archive[harchive].streams)) { _archive_error = ARC_NO_MEMORY; return (VOID_H_ARCHIVE); } /* Get state and lock for write access */ if (!OpenStateForWrite(harchive)) { _archive_error = _archive[harchive].last_error; return (VOID_H_ARCHIVE); } _n_archives++; /* Start the purge thread... */ archive = &_archive[harchive]; if (archive->state.thres_bytes != VOID_UINT64) { MUTEX_LOCK(&archive->purge.mutex); if(!archive->purge.active ) { ArchiveLog(ARC_LOG_VERBOSE, "Starting purge thread"); if(!THREAD_CREATE(&archive->purge.thread_id, PurgeThread, &archive->purge)) { MUTEX_UNLOCK(&archive->purge.mutex); _archive_error = ARC_PURGE_THREAD; return (VOID_H_ARCHIVE); } } MUTEX_UNLOCK(&archive->purge.mutex); } return (harchive); }
/*---------------------------------------------------------------------*/ H_ARCHIVE ArchiveOpenForRead(CHAR * path) { H_ARCHIVE harchive; ArchiveLog(ARC_LOG_VERBOSE, "Open archive for read: %s", path); _archive_error = ARC_NO_ERROR; /* Get next available handle */ if ((harchive = GetNextHandle()) == VOID_H_ARCHIVE) { ArchiveLog(ARC_LOG_ERRORS, "ArchiveOpenForRead: No available handle"); return (VOID_H_ARCHIVE); } _archive[harchive].last_error = ARC_NO_ERROR; /* Check out the path */ if (!ValidatePath(path, harchive)) { ArchiveLog(ARC_LOG_ERRORS, "ArchiveOpenForRead: Invalid path: %s", path); return (VOID_H_ARCHIVE); } /* Create stream list */ if (!CreateList(&_archive[harchive].streams)) { _archive_error = ARC_NO_MEMORY; ArchiveLog(ARC_LOG_ERRORS, "ArchiveOpenForRead: out of memory"); return (VOID_H_ARCHIVE); } /* Get state and open for read access */ if (!OpenStateForRead(harchive)) { _archive_error = _archive[harchive].last_error; ArchiveLog(ARC_LOG_ERRORS, "ArchiveOpenForRead: cannot get archive state"); return (VOID_H_ARCHIVE); } _n_archives++; return (harchive); }
/////////////////////////////////////////////////////////////////////////////// // Descripcion: // - Instala una nueva alarma de tiempo. // Parametros: // - pClient. Direccion del cliente. // - fTime. Tiempo en que se querra activar la alarma. // Devuelve: // - Handle asociada a la alarma. En caso de que el handle sea 0, habra // ocurrido un problema. // Notas: // - Se permitira asociar alarmas con valores menores o iguales a 0. Dichas // alarmas seran, naturalmente, de notificacion inmediata. // - Los nodos estaran colocados de menor tiempo a mayor tiempo. /////////////////////////////////////////////////////////////////////////////// AlarmDefs::AlarmHandle CAlarmManager::InstallTimeAlarm(iCAlarmClient* const pClient, const float fTime) { // SOLO si instancia inicializada ASSERT(IsInitOk()); // SOLO si parametros correctos ASSERT(pClient); // Se localiza nodo de tiempos adecuado, si es que hay alguno. AlarmTimeListIt AlarmsIt(m_TimeAlarms.Alarms.begin()); for (; AlarmsIt != m_TimeAlarms.Alarms.end(); ++AlarmsIt) { // ¿No hay nodo igual o bien se hallo un nodo con el mismo valor? if ((*AlarmsIt)->fAlarmTime >= fTime) { break; } } // Se crea nuevo nodo const AlarmDefs::AlarmHandle hAlarm = GetNextHandle(AlarmDefs::TIME_ALARM); ASSERT(hAlarm); sNTimeClientInfo* const pNewClient = new sNTimeClientInfo(pClient, hAlarm); ASSERT(pNewClient); // ¿Se hallo nodo con el mismo valor temporal? if (AlarmsIt != m_TimeAlarms.Alarms.end() && (*AlarmsIt)->fAlarmTime == fTime) { (*AlarmsIt)->Clients.push_back(pNewClient); } else { // No, hay que crear un nuevo nodo e insertarlo DESPUES (del localizado o final) sNAlarmTime* const pNewTime = new sNAlarmTime(fTime); m_TimeAlarms.Alarms.insert(AlarmsIt, pNewTime); // Por ultimo, se inserta el cliente pNewTime->Clients.push_back(pNewClient); } // Se retorna handle a la alarma return hAlarm; }
/////////////////////////////////////////////////////////////////////////////// // Descripcion: // - Instala una nueva alarma asociada a fichero WAV // Parametros: // - pClient. Direccion del cliente. // - hWAVSound. Handle al fichero wav. // Devuelve: // - Handle asociada a la alarma. En caso de que el handle sea 0, habra // ocurrido un problema. // Notas: /////////////////////////////////////////////////////////////////////////////// AlarmDefs::AlarmHandle CAlarmManager::InstallWAVAlarm(iCAlarmClient* const pClient, const ResDefs::WAVSoundHandle& hWAVSound) { // SOLO si instancia inicializada ASSERT(IsInitOk()); // SOLO si parametros correctos ASSERT(pClient); ASSERT(hWAVSound); // Se crea un nuevo nodo const AlarmDefs::AlarmHandle hAlarm = GetNextHandle(AlarmDefs::WAV_ALARM); ASSERT(hAlarm); sNWAVClientInfo* const pNewClient = new sNWAVClientInfo(pClient, hWAVSound, hAlarm); ASSERT(pNewClient); // Se inserta en la lista de clientes m_WAVAlarms.Alarms.push_back(pNewClient); // Se retorna handle a la alarma return hAlarm; }