+ /**
+ * Get the metadata cache
+ * @return \pq\Gateway\Table\CacheInterface
+ */
+ function getMetadataCache() {
+ if (!isset($this->metadatCache)) {
+ $this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache;
+ }
+ return $this->metadataCache;
+ }
+
+ /**
+ * Set the metadata cache
+ * @param \pq\Gateway\Table\CacheInterface $cache
+ */
+ function setMetadataCache(Table\CacheInterface $cache) {
+ $this->metadataCache = $cache;
+ return $this;
+ }
+
+ /**
+ * Get the primary key
+ * @return \pq\Gateway\Table\Identity
+ */
+ function getIdentity() {
+ if (!isset($this->identity)) {
+ $this->identity = new Table\Identity($this);
+ }
+ return $this->identity;
+ }
+
+ /**
+ * Get the table attribute definition (column list)
+ * @return \pq\Table\Attributes
+ */
+ function getAttributes() {
+ if (!isset($this->attributes)) {
+ $this->attributes = new Table\Attributes($this);
+ }
+ return $this->attributes;
+ }
+
+ /**
+ * Get foreign key relations
+ * @return \pq\Gateway\Table\Relations
+ */
+ function getRelations() {
+ if (!isset($this->relations)) {
+ $this->relations = new Table\Relations($this);
+ }
+ return $this->relations;
+ }
+
+ /**
+ * Get a foreign key relation
+ * @param string $table
+ * @param string $ref
+ * @return \pq\Gateway\Table\Reference
+ */
+ function getRelation($table, $ref = null) {
+ return $this->getRelations()->getReference($table, $ref);
+ }
+