File_Therion_DataTypes
[ class tree: File_Therion_DataTypes ] [ index: File_Therion_DataTypes ] [ all elements ]

Class: File_Therion_Reference

Source Location: /File_Therion-0.4.1/File/Therion/DataTypes/Reference.php

Class Overview

File_Therion_DataType
   |
   --File_Therion_Reference

Class representing a therion object reference.


Author(s):

Copyright:

  • 2016 Benedikt Hallinger

Variables

Methods


Inherited Variables

Inherited Methods

Class: File_Therion_DataType

File_Therion_DataType::parse()
Parse string content into this datatype
File_Therion_DataType::toString()
Get string representation
File_Therion_DataType::__toString()
Magic __toString() method calls toString().

Class Details

[line 51]
Class representing a therion object reference.

Some objects like Stations, scraps, etc. can be referenced. An example is an equate command linking two stations together. If the station is not locally known, it must be referenced and resolved. Therion provides a special syntax for this: "<ID>@<SubSurvey>.<Survey>", so an object can be referenced in survey structures. Note that it is not possible to reference objects in parent surveys, only lower levels may be referenced.

A Reference-object implements a specific object as viewed from some context.

The main intention of this class is PACKAGE INTERNAL USE, to make dealing parsing/resolving references easy. Under normal circumstances you should not need to use references yourself. The package will create them automatically when neccessary.

Two basic use cases exist:

  1.  // Dereference string reference to object (lookup object)
  2.  // (assuming structure: SurveyTop -> Subsurvey[Station_1])
  3.  $ref       = new File_Therion_Reference("1@Subsurvey"$topSurveyObj);
  4.  $station1  $ref->getObject();
  5.  
  6.  // Create string reference from Object
  7.  $ref       = new File_Therion_Reference($station1$topSurveyObj);
  8.  $stringRef $ref->toString();  // = "1@Subsurvey"



[ Top ]


Class Variables

$_ctx =  null

[line 60]

Viewing context.
  • Var: survey context
  • Access: protected



[ Top ]

$_obj =  null

[line 67]

The referenced object.
  • Var: survey context
  • Access: protected



[ Top ]

$_stringRef =  ""

[line 74]

The string representation of the reference.
  • Var: survey context
  • Access: protected



[ Top ]



Method Detail

__construct (Constructor)   [line 93]

File_Therion_Reference __construct( string|object $refObj, File_Therion_Survey $ctx)

Create a new therion reference object.

This generates a new reference object. The following invocations exist:

  • (obj, survey): Create obj reference (to generate string-reference).
  • (string, survey): Create resolvable string-reference.
More special invocations are:
  • (string, null): Create a contextless static ref (returns string as is)
  • (obj, null): Create fake obj reference (generates entire pathref).

  • Todo: better syntax check when string reference was given
  • Throws: InvalidArgumentException
  • Access: public

Parameters:

string|object    $refObj   —  The object to reference
File_Therion_Survey   $ctx   —  Viewing context

[ Top ]

getObject   [line 278]

File_Therion_IReferenceable getObject( )

Return referenced object by string reference.

In case the string reference was not resolved yet, it will be looked up. You usually dont need to call this yourself ({@see getObject()}).

This will throw an UnexpectedValueException when the view context is invalid. A File_Therion_InvalidReferenceException will be thrown, when the referenced object cannot be found in the data model.

  • Return: object (station, etc)
  • Throws: File_Therion_InvalidReferenceException for resolving errors
  • Throws: UnexpectedValueException when view-context is not available
  • Access: public

[ Top ]

getSurveyPath   [line 209]

array getSurveyPath( )

Retrieves the path leading to the objects survey context.

Objects must be associated to a survey. The surveys of the Object must be reachable from the survey context of the reference (viewing ctx), which is usually the parent survey referencing station of subsurveys.

When the references viewing context is not set (null), the topmost Object context will be used as top parent. This will result in the maximum possible path being resolved. When the Objects context is null, an UnexpectedValueException is thrown. When the Objects context is not reachable from the reference context, a File_Therion_InvalidReferenceException will be thrown.

Technically the search is done by walking the objects survey context structure upwards until the viewing survey context is reached.

The array returned is one of the following:

  • array containing no elements: Object is local to viewing context
  • array containing n elements: top-down path of surveys

  • Return: indexed array with survey objects representing survey path
  • Throws: File_Therion_InvalidReferenceException for resolving errors
  • Throws: UnexpectedValueException when context is not available
  • Access: public

[ Top ]

parse   [line 146]

File_Therion_Reference parse( $string $string)

Parse string reference into static reference object.

This will create a basic string reference object without context. As such, it is just a kind of alias to the constructor for static string references.

  • Access: public

Overrides File_Therion_DataType::parse() (Parse string content into this datatype)

Parameters:

$string   $string   —  reference to parse

[ Top ]

toString   [line 127]

Therion toString( )

Get string representation.

The string reference will be generated in case it was not already present. To be sure you always have an up-to-date reference, you may call updateStringReference() manually beforehand.

  • Return: compliant String of this reference
  • Access: public

Overrides File_Therion_DataType::toString() (Get string representation)
[ Top ]

updateObjectReference   [line 300]

void updateObjectReference( )

Parse string reference and resolve referenced object.

This will take the current string reference and uses the view-context to lookup the referenced object.

  • Todo: support more objects like scraps, maps etc
  • Throws: UnexpectedValueException when view-context is not available
  • Throws: File_Therion_InvalidReferenceException for resolving errors
  • Access: public

[ Top ]

updateStringReference   [line 168]

void updateStringReference( )

Update string representation of this reference.

This will generate a string reference that will be returned by toString(). The reference addresses the current referenced object viewed from the reference view-context. You usually don't need to call this yourself ({@see toString()}).

As of therion 5.3.16 and Survex 1.2.16 the reference syntax looks like with deep nested structures the path syntax is resolved right-to-left as top-down, with the dot just beeing an alternate @-sign. eg.: "1.1@deepest.notSoDeep.topSurvey": saying"1.1 at deepest@notSoDeep@topSurvey", while topSurvey is the next reachable level from the current viewed one.

  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:09:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.