blob: aacd997ee58697394c7a412527ef548e4c92432d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// See LICENSE for license details.
package firrtl.options
import firrtl.AnnotationSeq
/** Type class defining a "view" of an [[AnnotationSeq]]
* @tparam T the type to which this viewer converts an [[AnnotationSeq]] to
*/
trait OptionsView[T] {
/** Convert an [[AnnotationSeq]] to some other type
* @param options some annotations
*/
def view(options: AnnotationSeq): T
}
/** A shim to manage multiple "views" of an [[AnnotationSeq]] */
object Viewer {
/** Convert annotations to options using an implicitly provided [[OptionsView]]
* @param options some annotations
* @param optionsView a converter of options to the requested type
* @tparam T the type to which the input [[AnnotationSeq]] should be viewed as
*/
def view[T](options: AnnotationSeq)(implicit optionsView: OptionsView[T]): T = optionsView.view(options)
}
|