
1 // 2 // Copyright (c) 2006, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 4 Jan 06 Brian Frank Creation 7 // 8 9 ** 10 ** Pod represents a module of Types. Pods serve as a type namespace 11 ** as well as unit of deployment and versioning. 12 ** 13 final class Pod 14 { 15 16 ////////////////////////////////////////////////////////////////////////// 17 // Management 18 ////////////////////////////////////////////////////////////////////////// 19 20 ** 21 ** Get a list of all the pods installed. Note that currently this 22 ** method will load all of the pods into memory, so it is an expensive 23 ** operation. 24 ** 25 static Pod[] list() 26 27 ** 28 ** Find a pod by name. If the pod doesn't exist and checked 29 ** is false then return null, otherwise throw UnknownPodErr. 30 ** 31 static Pod find(Str name, Bool checked := true) 32 33 ** 34 ** Load a pod into memory from the specified input stream. The 35 ** stream must contain a valid pod zip file with the all the definitions. 36 ** The pod is completely loaded into memory and the input stream is 37 ** closed. The pod cannot have resources. The pod name as defined 38 ** by '/pod.def' must be uniquely named or Err is thrown. 39 ** 40 static Pod load(InStream in) 41 42 ////////////////////////////////////////////////////////////////////////// 43 // Constructor 44 ////////////////////////////////////////////////////////////////////////// 45 46 ** 47 ** Private constructor. 48 ** 49 private new make() 50 51 ////////////////////////////////////////////////////////////////////////// 52 // Identity 53 ////////////////////////////////////////////////////////////////////////// 54 55 ** 56 ** Simple name of the pod such as "sys". 57 ** 58 Str name() 59 60 ** 61 ** Version number for this pod. 62 ** 63 Version version() 64 65 ** 66 ** Get the declared list of dependencies for this pod. 67 ** 68 Depend[] depends() 69 70 ////////////////////////////////////////////////////////////////////////// 71 // Facets 72 ////////////////////////////////////////////////////////////////////////// 73 74 ** 75 ** Return all the facets defined for this pod or an empty map 76 ** if no facets are defined. See the [Facets Doc]`docLang::Facets` 77 ** for details. 78 ** 79 Str:Obj facets() 80 81 ** 82 ** Get a facet by name, or return the 'def' is the facet is not defined. 83 ** See the [Facets Doc]`docLang::Facets` for details. 84 ** 85 Obj facet(Str name, Obj def := null) 86 87 ////////////////////////////////////////////////////////////////////////// 88 // Types 89 ////////////////////////////////////////////////////////////////////////// 90 91 ** 92 ** List of the all defined types. 93 ** 94 Type[] types() 95 96 ** 97 ** Find a type by name. If the type doesn't exist and checked 98 ** is false then return null, otherwise throw UnknownTypeErr. 99 ** 100 Type findType(Str name, Bool checked := true) 101 102 ////////////////////////////////////////////////////////////////////////// 103 // Resource Files 104 ////////////////////////////////////////////////////////////////////////// 105 106 ** 107 ** Get the map of all the resource files contained by this pod. 108 ** Resources are any files included in the pod's zip file excluding 109 ** fcode files. The files are keyed by their Uri relative to the 110 ** root of the pod zip file. 111 ** 112 Uri:File files() 113 114 ////////////////////////////////////////////////////////////////////////// 115 // Conversion 116 ////////////////////////////////////////////////////////////////////////// 117 118 ** 119 ** Always return name(). 120 ** 121 override Str toStr() 122 123 }