Searching for objects


Functions

char * find_file (char *name, char *path, int mode)
 Search for a file in the specified path (or in GLPATH environment variable) access flags: 0 = exist only, 2 = write, 4 = read, 6 = read/write.
OBJECTfind_first (FINDLIST *list)
 Returns the first object currently in the the search list return.
int find_makearray (FINDLIST *list, OBJECT ***objs)
 Makes an array from the objects currently in the search list result.
OBJECTfind_next (FINDLIST *list, OBJECT *obj)
 Return the next object in the currenet search list.
FINDLIST * find_objects (FINDLIST *start,...)
 Search for objects that match criteria start may be a previous search result, or FT_NEW.
FINDLIST * findlist_copy (FINDLIST *list)
 Make a copy of a findlist.


Function Documentation

char* find_file ( char *  name,
char *  path,
int  mode 
)

Search for a file in the specified path (or in GLPATH environment variable) access flags: 0 = exist only, 2 = write, 4 = read, 6 = read/write.

Returns:
the first occurance of the file having the desired access mode
Parameters:
name  the name of the file to find
path  the path to search (or NULL to search the GLPATH environment)
mode  the file access mode to use, see access() for valid modes

Definition at line 1265 of file find.c.

Referenced by legal_notice(), load_tzspecs(), loadall(), module_load(), and unit_init().

OBJECT* find_first ( FINDLIST *  list  )  [read]

Returns the first object currently in the the search list return.

Returns:
a pointer to the first object
Parameters:
list  the search list to scan

Definition at line 516 of file find.c.

References find_next().

Referenced by aggregate_mkgroup(), aggregate_value(), cmex_object_list(), exec_debug_cmd(), find_makearray(), and random_apply().

int find_makearray ( FINDLIST *  list,
OBJECT ***  objs 
)

Makes an array from the objects currently in the search list result.

Returns:
The number of objects found
Parameters:
list  the search list to scan
objs  the object found

Definition at line 498 of file find.c.

References find_first(), and find_next().

OBJECT* find_next ( FINDLIST *  list,
OBJECT obj 
) [read]

Return the next object in the currenet search list.

Returns:
a pointer to the next object
Parameters:
list  the search list to scan
obj  the current object

Definition at line 524 of file find.c.

References object_get_first().

Referenced by aggregate_value(), cmex_object_list(), exec_debug_cmd(), find_first(), find_makearray(), and random_apply().

FINDLIST* find_objects ( FINDLIST *  start,
  ... 
)

Search for objects that match criteria start may be a previous search result, or FT_NEW.

FT_NEW starts a new search (starting with all objects)

Searches criteria may be as follows:

find_objects(FT_NEW, ftype, compare, value[, ...], NULL);

and may be grouped using AND and OR.

The criteria list must be terminated by NULL or FT_END.

Values of ftype are:

  • FT_ID compares object ids (expects long value)
  • FT_SIZE compares object size excluding header (expects long value)
  • FT_CLASS compares object class name (expects char* value)
  • FT_PARENT uses parent for comparison (must be followed by another ftype)
  • FT_RANK compares object rank by number (expects long value)
  • FT_CLOCK compares object clock (expects TIMESTAMP value)
  • FT_PROPERTY compares property (expects char* value)
  • FT_MODULE compares module name

Extended values of ftype are:

  • CF_NAME looks for a particular name
  • CF_LATT compares object lattitudes
  • CF_LONG compares object longitudes
  • CF_INSVC checks in-service timestamp
  • CF_OUTSVC checks out-service timestamp

Values of compare are:

  • EQ equal
  • NE not equal
  • LT less than
  • GT greater than
  • LE less than or equal
  • GE greather than or equal
  • NOT opposite of test
  • BETWEEN in between
  • SAME same string
  • BEFORE alphabetic before
  • AFTER alphabetic after
  • DIFF alphabetic differ
  • MATCH matches regex
  • LIKE matches regex
  • UNLIKE matches "not" regex

Conjunctions are AND and OR, and can be used to do complex searches

OBJECT *find_first(FINDLIST *list) returns the first object in the result list

OBJECT *find_next(FINDLIST *list, OBJECT *previous) returns the next object in the result list

Returns:
a pointer for FINDLIST structure used by find_first(), find_next, and find_makearray(), will return NULL if an error occurs.

Definition at line 353 of file find.c.

References object_get_count(), object_get_first(), and output_error().

Referenced by cmex_object_list(), exec_debug_cmd(), and random_apply().

FINDLIST* findlist_copy ( FINDLIST *  list  ) 

Make a copy of a findlist.

This is necessary because find_object changes the list it's given so if you want to run a search repeatedly, you need to work on a copy. Don't forget to free the copy when you're done using it.

Returns:
the copy

Definition at line 684 of file find.c.


GridLAB-DTM Version 2.0
An open-source project initiated by the US Department of Energy