Changeset 397
- Timestamp:
- Apr 7, 2004, 4:13:17 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r391 r397 1 %%% $Id: psLibSDRS.tex,v 1.3 2 2004-04-07 03:26:07 eugene Exp $1 %%% $Id: psLibSDRS.tex,v 1.33 2004-04-08 02:13:17 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 487 487 488 488 \tbd{REF}. 489 490 \subsubsection{Relation of Memory Management to Structures} 491 492 In this document, we specify several C \code{struct}s. It is expected 493 that instances of, for example, \code{struct psMyType} will be 494 constructed using \code{psMyTypeAlloc()} calls, and destructed using 495 \code{psMyTypeFree()} calls. The allocator will allocate the required 496 memory with \code{psAlloc} and increment the appropriate 497 \code{refCounter}. The destructor will decrement the appropriate 498 \code{refCounter} and free the memory with \code{psFree} \emph{if and 499 only if} the new value of the \code{refCounter} is zero. 500 501 This allows the \code{psMyType} to be imported into the metadata 502 (\S\ref{sec:metadata}) without the user worrying about the details of 503 the memory allocation/deallocation. For example: 504 505 \begin{verbatim} 506 void psFooMetadata(psMetadata *md) 507 { 508 psFoo *foo = psFooAlloc(); 509 (void) psMetaDataAppend(md, psMetaDataItemAlloc(PS_META_FOO,foo,"Comment","foo.bar")); 510 (void) psFooFree(foo); 511 } 512 \end{verbatim} 513 514 In the above case, \code{foo} is created, stuffed into the metadata, 515 and then the programmer follows the rule of ``for every \code{alloc}, 516 there is an equal and opposite free'' before the function returns. 517 However, the metadata needs to carry around the \code{psFoo}, and so 518 it is important that \code{psFooFree} does not free the memory for 519 \code{foo}, but only decrements its \code{refCounter}. Hence, at the 520 conclusion of the function, the memory pointed to by \code{foo} in the 521 course of the function remains allocated, and the corresponding 522 \code{refCounter} is 1 (specifically, the reference in the metadata). 489 523 490 524 \subsection{Tracing and Logging} … … 1016 1050 \code{psDlist} may have changed. The value of \code{where} specifies 1017 1051 if the specified data item should be placed on the front of the list 1018 (\code{PS_DLIST_HEAD}), or at the end of the list 1019 (\code{PS_DLIST_TAIL}). 1052 (\code{PS_DLIST_HEAD}), at the end of the list (\code{PS_DLIST_TAIL}), 1053 to add after (\code{PS_DLIST_NEXT}) or before (\code{PS_DLIST_PREV}) 1054 the current element (specified by the iteration cursor), or an index 1055 that the new \code{data} should inhabit. 1020 1056 1021 1057 A data item may be retrieved from the list with the function: … … 2329 2365 2330 2366 \subsection{Metadata} 2367 \label{sec:metadata} 2331 2368 2332 2369 \subsubsection{Conceptual Overview} … … 2397 2434 manipulation of the data should be reflected in the metadata where 2398 2435 appropriate. This is always an issue of concern. For example, 2399 consider an image of dimensions \code{ Nx, Ny}. If a function extracts2400 a subraster, it must change the values of \code{ Nx, Ny} to match the2436 consider an image of dimensions \code{nX, nY}. If a function extracts 2437 a subraster, it must change the values of \code{nX, nY} to match the 2401 2438 new dimensions. What should it do to the corresponding metadata? 2402 2439 Clearly, it should change the corresponding value which defines 2403 \code{ Nx, Ny}. However, it is not quite so simple: there may be other2440 \code{nX, nY}. However, it is not quite so simple: there may be other 2404 2441 metadata values which depend on those values. These must also be 2405 2442 changed appropriately. What if the metadata element points to a … … 2414 2451 image exposure time is a notorious example in astronomy. Different 2415 2452 observatories use different header keywords (ie, metadata names) for 2416 the same concept of the exposure time ( EXPTIME, EXPOSURE, OPENTIME,2417 INTTIME, etc). Any system which operates on these metadata needs to 2418 address the issue of identifying these names. This issue seems like an 2419 argument for hardwiring metadata in the structure, but in fact it does 2420 not present such a strong case. If the metadata are hardwired, some 2421 function will still have to know how to interpret the various names to 2422 populate the structure. The concept can still be localized with 2423 generic metadata containers by including abstract metadata names 2424 within the code which are tied to the various implementations-specific 2425 metadata names. 2453 the same concept of the exposure time (\code{EXPTIME}, 2454 \code{EXPOSURE}, \code{OPENTIME}, \code{INTTIME}, etc). Any system 2455 which operates on these metadata needs to address the issue of 2456 identifying these names. This issue seems like an argument for 2457 hardwiring metadata in the structure, but in fact it does not present 2458 such a strong case. If the metadata are hardwired, some function will 2459 still have to know how to interpret the various names to populate the 2460 structure. The concept can still be localized with generic metadata 2461 containers by including abstract metadata names within the code which 2462 are tied to the various implementations-specific metadata names. 2426 2463 2427 2464 \subsubsection{Metadata Representation} … … 2510 2547 \end{verbatim} 2511 2548 2512 The type \code{psMetaDataSet} is a container class for metadata. Note that there are 2513 in fact \emph{two} representations of the metadata (each \code{psMetaDataItem} appears 2514 on both). 2515 2516 We are using the standard \PS{} doubly-linked list types 2517 \code{psDlist} and \code{psHash}. For example: 2549 The type \code{psMetaDataSet} is a container class for metadata. Note 2550 that there are in fact \emph{two} representations of the metadata 2551 (each \code{psMetaDataItem} appears on both). The first 2552 representation employs a doubly-linked list that allows the order of 2553 the metadata to be preserved (e.g., if FITS headers are read in a 2554 particular order, they should be written in the same order). The 2555 second representation employs a hash table which allows fast look-up 2556 given a specific metadata keyword. 2557 2558 When we refer to ``metadata'' (especially in the case of images), we 2559 generally mean a \code{psMetaDataSet}: 2560 \begin{verbatim} 2561 typedef psMetaDataSet psMetadata; 2562 \end{verbatim} 2563 2564 An example of the usage of the metadata APIs is as follows: 2518 2565 \begin{verbatim} 2519 2566 for (int i = 0; i < 10; i += 5) { … … 2574 2621 \end{verbatim} 2575 2622 2576 It is an unfortunate fact that certain metadata keywords (such as \code{COMMENT} in a FITS header) 2577 may be repeated with different values. The \code{psMetaDataAppend} routine is required 2578 to check that all metadata names are unique unless the type is qualified as \code{PS_META_NON_UNIQUE}; 2579 in this case a unique integer will be added to each name that you specify. In this case, 2580 you may either delete individual element separately or as a complete set: 2623 It is an unfortunate fact that certain metadata keywords (such as 2624 \code{COMMENT} and \code{HISTORY} in a FITS header) may be repeated 2625 with different values. The \code{psMetaDataAppend} routine is 2626 required to check that all metadata names are unique unless the type 2627 is qualified as \code{PS_META_NON_UNIQUE}; in this case a unique 2628 integer will be added to each name that you specify. In this case, you 2629 may either delete individual element separately or as a complete set: 2581 2630 \begin{verbatim} 2582 2631 psMetaDataItemFree(psMetaDataRemove(ms, "lang.hello.0")); … … 2585 2634 2586 2635 \subsubsection{MetaData APIs} 2636 2637 In this section, we explain the metadata APIs more fully. 2638 2639 The allocator for \code{psMetaDataItem} returns a full 2640 \code{psMetaDataItem} ready for insertion into the 2641 \code{psMetaDataSet}. It is important to note that, in order to 2642 support multiple types, the data being input must be a pointer, even 2643 if it is a \code{float} or \code{int}, for example. The name of the 2644 \code{psMetaDataItem} takes a \code{sprintf} format string, with the 2645 corresponding arguments following. 2646 2647 Note that the destructor does not 2587 2648 2588 2649 \begin{verbatim}
Note:
See TracChangeset
for help on using the changeset viewer.
