void LLInventoryFilter::setHoursAgo(U32 hours) { if (mFilterOps.mHoursAgo != hours) { bool are_date_limits_valid = mFilterOps.mMinDate == time_min() && mFilterOps.mMaxDate == time_max(); bool is_increasing = hours > mFilterOps.mHoursAgo; bool is_increasing_from_zero = is_increasing && !mFilterOps.mHoursAgo; // *NOTE: need to cache last filter time, in case filter goes stale BOOL less_restrictive = ((are_date_limits_valid && ((is_increasing && mFilterOps.mHoursAgo))) || !hours); BOOL more_restrictive = ((are_date_limits_valid && (!is_increasing && hours)) || is_increasing_from_zero); mFilterOps.mHoursAgo = hours; mFilterOps.mMinDate = time_min(); mFilterOps.mMaxDate = time_max(); if (less_restrictive) { setModified(FILTER_LESS_RESTRICTIVE); } else if (more_restrictive) { setModified(FILTER_MORE_RESTRICTIVE); } else { setModified(FILTER_RESTART); } } mFilterOps.mFilterTypes |= FILTERTYPE_DATE; }
void LLInventoryFilter::setHoursAgo(U32 hours) { if (mFilterOps.mHoursAgo != hours) { // *NOTE: need to cache last filter time, in case filter goes stale BOOL less_restrictive = (mFilterOps.mMinDate == time_min() && mFilterOps.mMaxDate == time_max() && hours > mFilterOps.mHoursAgo); BOOL more_restrictive = (mFilterOps.mMinDate == time_min() && mFilterOps.mMaxDate == time_max() && hours <= mFilterOps.mHoursAgo); mFilterOps.mHoursAgo = hours; mFilterOps.mMinDate = time_min(); mFilterOps.mMaxDate = time_max(); if (less_restrictive) { setModified(FILTER_LESS_RESTRICTIVE); } else if (more_restrictive) { setModified(FILTER_MORE_RESTRICTIVE); } else { setModified(FILTER_RESTART); } } mFilterOps.mFilterTypes |= FILTERTYPE_DATE; }
void LLInventoryFilter::setHoursAgo(U32 hours) { if (mFilterOps.mHoursAgo != hours) { bool are_date_limits_valid = mFilterOps.mMinDate == time_min() && mFilterOps.mMaxDate == time_max(); bool is_increasing = hours > mFilterOps.mHoursAgo; bool is_decreasing = hours < mFilterOps.mHoursAgo; bool is_increasing_from_zero = is_increasing && !mFilterOps.mHoursAgo && !isSinceLogoff(); // *NOTE: need to cache last filter time, in case filter goes stale BOOL less_restrictive; BOOL more_restrictive; if (FILTERDATEDIRECTION_NEWER == mFilterOps.mDateSearchDirection) { less_restrictive = ((are_date_limits_valid && ((is_increasing && mFilterOps.mHoursAgo))) || !hours); more_restrictive = ((are_date_limits_valid && (!is_increasing && hours)) || is_increasing_from_zero); } else { less_restrictive = ((are_date_limits_valid && ((is_decreasing && mFilterOps.mHoursAgo))) || !hours); more_restrictive = ((are_date_limits_valid && (!is_decreasing && hours)) || is_increasing_from_zero); } mFilterOps.mHoursAgo = hours; mFilterOps.mMinDate = time_min(); mFilterOps.mMaxDate = time_max(); if (less_restrictive) { setModified(FILTER_LESS_RESTRICTIVE); } else if (more_restrictive) { setModified(FILTER_MORE_RESTRICTIVE); } else { setModified(FILTER_RESTART); } } if (areDateLimitsSet()) { mFilterOps.mFilterTypes |= FILTERTYPE_DATE; } else { mFilterOps.mFilterTypes &= ~FILTERTYPE_DATE; } }
/* Return a well formatted string with a time difference at millisecond resolution */ char * elapsed_time (struct timeval * start, struct timeval * stop) { static char et [64]; time_t elapsed = delta_time_in_milliseconds (stop, start); if (time_day (elapsed)) sprintf (et, "%d days, %02d:%02d:%02d.%03ld", time_day (elapsed), time_hour (elapsed), time_min (elapsed), time_sec (elapsed), time_usec (elapsed)); else if (time_hour (elapsed)) sprintf (et, "%02d:%02d:%02d.%03ld", time_hour (elapsed), time_min (elapsed), time_sec (elapsed), time_usec (elapsed)); else if (time_min (elapsed)) sprintf (et, "%02d:%02d.%03ld", time_min (elapsed), time_sec (elapsed), time_usec (elapsed)); else if (time_sec (elapsed)) sprintf (et, "%d.%03d secs", time_sec (elapsed), time_msec (elapsed)); else sprintf (et, "%3d msecs", time_msec (elapsed)); return et; }
BOOL LLInventoryFilter::isActive() const { return mFilterOps.mFilterObjectTypes != 0xffffffffffffffffULL || mFilterOps.mFilterCategoryTypes != 0xffffffffffffffffULL || mFilterOps.mFilterWearableTypes != 0xffffffffffffffffULL || mFilterOps.mFilterTypes != FILTERTYPE_OBJECT || mFilterOps.mFilterLinks != FILTERLINK_INCLUDE_LINKS || mFilterSubString.size() || mFilterOps.mPermissions != PERM_NONE || mFilterOps.mMinDate != time_min() || mFilterOps.mMaxDate != time_max() || mFilterOps.mHoursAgo != 0; }
LLInventoryFilter::FilterOps::FilterOps() : mFilterObjectTypes(0xffffffffffffffffULL), mFilterCategoryTypes(0xffffffffffffffffULL), mFilterWearableTypes(0xffffffffffffffffULL), mMinDate(time_min()), mMaxDate(time_max()), mHoursAgo(0), mShowFolderState(SHOW_NON_EMPTY_FOLDERS), mPermissions(PERM_NONE), mFilterTypes(FILTERTYPE_OBJECT), mFilterUUID(LLUUID::null), mFilterLinks(FILTERLINK_INCLUDE_LINKS) { }
int main(int argc, char **argv) { cst_voice *v; char thetime[1024]; char b[3]; int hour, min; cst_regex *timex; char *output = "play"; if (argc != 2) { fprintf(stderr,"usage: flite_time HH:MM\n"); exit(-1); } timex = new_cst_regex("[012][0-9]:[0-5][0-9]"); if (!cst_regex_match(timex,argv[1])) { fprintf(stderr,"not a valid time\n"); fprintf(stderr,"usage: flite_time HH:MM\n"); exit(-1); } delete_cst_regex(timex); b[2] = '\0'; b[0] = argv[1][0]; b[1] = argv[1][1]; hour = atoi(b); b[0] = argv[1][3]; b[1] = argv[1][4]; min = atoi(b); flite_init(); v = register_cmu_time_awb(NULL); sprintf(thetime, "The time is now, %s %s %s, %s.", time_approx(hour,min), time_min(hour,min), time_hour(hour,min), time_tod(hour,min)); printf("%s\n",thetime); flite_text_to_speech(thetime,v,output); return 0; }
void LLInventoryFilter::setDateRangeLastLogoff(BOOL sl) { if (sl && !isSinceLogoff()) { setDateRange(mLastLogoff, time_max()); setModified(); } if (!sl && isSinceLogoff()) { setDateRange(time_min(), time_max()); setModified(); } if (areDateLimitsSet()) { mFilterOps.mFilterTypes |= FILTERTYPE_DATE; } else { mFilterOps.mFilterTypes &= ~FILTERTYPE_DATE; } }
void LLInventoryFilter::setDateRangeLastLogoff(BOOL sl) { static LLCachedControl<U32> s_last_logoff(gSavedPerAccountSettings, "LastLogoff", 0); if (sl && !isSinceLogoff()) { setDateRange(s_last_logoff(), time_max()); setModified(); } if (!sl && isSinceLogoff()) { setDateRange(time_min(), time_max()); setModified(); } if (areDateLimitsSet()) { mFilterOps.mFilterTypes |= FILTERTYPE_DATE; } else { mFilterOps.mFilterTypes &= ~FILTERTYPE_DATE; } }
BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const { const LLFolderViewEventListener* listener = item->getListener(); if (!listener) return FALSE; LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); const U32 filterTypes = mFilterOps.mFilterTypes; //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_OBJECT // Pass if this item's type is of the correct filter type if (filterTypes & FILTERTYPE_OBJECT) { // If it has no type, pass it, unless it's a link. if (object_type == LLInventoryType::IT_NONE) { if (object && object->getIsLinkType()) { return FALSE; } } else if ((1LL << object_type & mFilterOps.mFilterObjectTypes) == U64(0)) { return FALSE; } } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_UUID // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { if (!object) return FALSE; if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_DATE // Pass if this item is within the date range. if (filterTypes & FILTERTYPE_DATE) { const U16 HOURS_TO_SECONDS = 3600; time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { earliest = mFilterOps.mMinDate; } else if (!mFilterOps.mHoursAgo) { earliest = 0; } if (listener->getCreationDate() < earliest || listener->getCreationDate() > mFilterOps.mMaxDate) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_WEARABLE // Pass if this item is a wearable of the appropriate type if (filterTypes & FILTERTYPE_WEARABLE) { LLWearableType::EType type = listener->getWearableType(); if ((0x1LL << type & mFilterOps.mFilterWearableTypes) == 0) { return FALSE; } } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_WORN // Pass if this item is worn (hiding COF and Outfits folders) if (filterTypes & FILTERTYPE_WORN) { if (!object) return FALSE; LLUUID cat_id = object->getParentUUID(); const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); return !LLAppearanceMgr::instance().getIsInCOF(object_id) && (!cat || cat->getPreferredType() != LLFolderType::FT_OUTFIT) && get_is_item_worn(object_id); } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_EMPTYFOLDERS // Pass if this item is a folder and is not a system folder that should be hidden if (filterTypes & FILTERTYPE_EMPTYFOLDERS) { if (object_type == LLInventoryType::IT_CATEGORY) { bool is_hidden_if_empty = LLViewerFolderType::lookupIsHiddenIfEmpty(listener->getPreferredType()); if (is_hidden_if_empty) { // Force the fetching of those folders so they are hidden iff they really are empty... gInventory.fetchDescendentsOf(object_id); return FALSE; } } } return TRUE; }
bool LLInventoryFilter::areDateLimitsSet() { return mFilterOps.mMinDate != time_min() || mFilterOps.mMaxDate != time_max() || mFilterOps.mHoursAgo != 0; }
int main(int argc, char **argv) { FILE *in; int first = 1, c = 0, NUM = 3; uintmax_t msec; unsigned int K, I; size_t r; char line[1024]; clock_t *time[3], t; char *name[] = {"taylor_log", "hyperbolic_log", "builtin_log"}; double *X_d; //Assumes that a single argument is given and that it is a file of // test values. sscanf(argv[2], "%u", &I); in = fopen(argv[1], "r"); if (in == NULL) { printf("File %s not found for reading\n", argv[1]); exit(1); } while(fgets(line, sizeof(line), in)) { if(first) { if(sscanf(line, "%u", &K) != 1) { printf("File %s incorrectly formatted\n", argv[1]); exit(2); } X_d = malloc(K * sizeof(*X_d)); for(int i = 0; i < NUM; ++i) time[i] = malloc(K * sizeof(**time)); first = 0; } else { if(sscanf(line, "%lf", &X_d[c]) != 1) printf("Line %d is incorrectly formatted\n", c+2); else ++c; } K = c; } fclose(in); int j; for(int i = 0; i < K; i++) { t = clock(); for(j=0; j < I; j++) taylor_nat_log(X_d[i], 34); time[0][i] = clock() - t; t = clock(); for(j=0; j < I; j++) hyperbolic_nat_log(X_d[i], 8); time[1][i] = clock() - t; t = clock(); for(j=0; j < I; j++) log(X_d[i]); time[2][i] = clock() - t; } for(int i = 0; i < NUM; i++) { msec = (uintmax_t)time_average(time[i], K) * 1000 / CLOCKS_PER_SEC; printf("Average time for %s: %lu.%03lus\n", name[i], msec/1000, msec % 1000); msec = (uintmax_t)time_total(time[i], K) * 1000 / CLOCKS_PER_SEC; printf("Total time for %s: %lu.%03lus\n", name[i], msec/1000, msec % 1000); msec = (uintmax_t)time_min(time[i], K) * 1000 / CLOCKS_PER_SEC; printf("Minimum time for %s: %lu.%03lus\n", name[i], msec/1000, msec % 1000); msec = (uintmax_t)time_max(time[i], K) * 1000 / CLOCKS_PER_SEC; printf("Maximum time for %s: %lu.%03lus\n", name[i], msec/1000, msec % 1000); printf("\n"); } }
BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const { const LLFolderViewEventListener* listener = item->getListener(); if (!listener) return FALSE; LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); const U32 filterTypes = mFilterOps.mFilterTypes; //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_OBJECT // Pass if this item's type is of the correct filter type if (filterTypes & FILTERTYPE_OBJECT) { // If it has no type, pass it, unless it's a link. if (object_type == LLInventoryType::IT_NONE) { if (object && object->getIsLinkType()) { return FALSE; } } else if ((1LL << object_type & mFilterOps.mFilterObjectTypes) == U64(0)) { return FALSE; } } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_CATEGORY // Pass if this item is a category of the filter type, or // if its parent is a category of the filter type. if (filterTypes & FILTERTYPE_CATEGORY) { // Can only filter categories for items in your inventory // (e.g. versus in-world object contents). if (!object) return FALSE; LLUUID cat_id = object_id; if (listener->getInventoryType() != LLInventoryType::IT_CATEGORY) { cat_id = object->getParentUUID(); } const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); if (!cat) return FALSE; if ((1LL << cat->getPreferredType() & mFilterOps.mFilterCategoryTypes) == U64(0)) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_UUID // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { if (!object) return FALSE; if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_DATE // Pass if this item is within the date range. if (filterTypes & FILTERTYPE_DATE) { const U16 HOURS_TO_SECONDS = 3600; time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { earliest = mFilterOps.mMinDate; } else if (!mFilterOps.mHoursAgo) { earliest = 0; } if (listener->getCreationDate() < earliest || listener->getCreationDate() > mFilterOps.mMaxDate) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_WEARABLE // Pass if this item is a wearable of the appropriate type if (filterTypes & FILTERTYPE_WEARABLE) { LLWearableType::EType type = listener->getWearableType(); if ((0x1LL << type & mFilterOps.mFilterWearableTypes) == 0) { return FALSE; } } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_WORN // Pass if this item is worn (hiding COF and Outfits folders) if (filterTypes & FILTERTYPE_WORN) { if (!object) return FALSE; LLUUID cat_id = object->getParentUUID(); const LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); return !LLAppearanceMgr::instance().getIsInCOF(object_id) && (!cat || cat->getPreferredType() != LLFolderType::FT_OUTFIT) && get_is_item_worn(object_id); } return TRUE; }
BOOL LLInventoryFilter::checkAgainstFilterType(const LLFolderViewItem* item) const { const LLFolderViewEventListener* listener = item->getListener(); if (!listener) return FALSE; LLInventoryType::EType object_type = listener->getInventoryType(); const LLUUID object_id = listener->getUUID(); const LLInventoryObject *object = gInventory.getObject(object_id); const U32 filterTypes = mFilterOps.mFilterTypes; //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_OBJECT // Pass if this item's type is of the correct filter type if (filterTypes & FILTERTYPE_OBJECT) { // If it has no type, pass it, unless it's a link. if (object_type == LLInventoryType::IT_NONE) { if (object && object->getIsLinkType()) { return FALSE; } } else if ((1LL << object_type & mFilterOps.mFilterObjectTypes) == U64(0)) { return FALSE; } } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_UUID // Pass if this item is the target UUID or if it links to the target UUID if (filterTypes & FILTERTYPE_UUID) { if (!object) return FALSE; if (object->getLinkedUUID() != mFilterOps.mFilterUUID) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_DATE // Pass if this item is within the date range. if (filterTypes & FILTERTYPE_DATE) { const U16 HOURS_TO_SECONDS = 3600; time_t earliest = time_corrected() - mFilterOps.mHoursAgo * HOURS_TO_SECONDS; if (mFilterOps.mMinDate > time_min() && mFilterOps.mMinDate < earliest) { earliest = mFilterOps.mMinDate; } else if (!mFilterOps.mHoursAgo) { earliest = 0; } if (listener->getCreationDate() < earliest || listener->getCreationDate() > mFilterOps.mMaxDate) return FALSE; } //////////////////////////////////////////////////////////////////////////////// // FILTERTYPE_WEARABLE // Pass if this item is a wearable of the appropriate type if (filterTypes & FILTERTYPE_WEARABLE) { LLWearableType::EType type = listener->getWearableType(); if ((0x1LL << type & mFilterOps.mFilterWearableTypes) == 0) { return FALSE; } } return TRUE; }