From GridLAB-D Wiki
Jump to: navigation, search

Syntax

[Done 3/7/09 --Dchassin 18:43, 8 March 2009 (UTC)]

We need to add support for name spaces. The idea is that the loader will interpret the following

namespace PartA {
  object X1 {
    // ...
  };
}
namespace PartB {
  object X1 {
    // ...
  };
}

in such a way that two objects are defined, one with the name PartA:X1 and the other PartB:X1.

In addition, any reference to an object name will be resolved in the current name space, so that

namespace PartA {
  object X1 {
    // ...
  };
  object {
    from X1; // reference to PartA implied
    to PartB:X1; // reference the other X1 in PartB
  };
}
namespace PartB {
  object X1 {
    // ...
  };
  object {
    from X1; // reference to PartB implied
    to PartA:X1; // reference the other X1 in PartA
  };
}

would resolve X1 correctly as PartA:X1 and PartB:X1 in each case.

Indexing

[To do]

Namespaces will be indexed. Declaration of a name space will result in the creation of an object index using full (i.e., nested) name of the namespace.

The index will be used to resolve objects in context or globally as necessary. This will make it unnecessary to index the full names of objects within namespaces.

The current index will be only for the global namespace, and each subspace will have an index of its own, and a list of all the namespaces within in.

Context

[Done 3/7/09 --Dchassin 18:43, 8 March 2009 (UTC)]

During the loading process, a global variable will be defined that contains the full name of the current namespace. This variable will be called namespace and can used referenced by glm files as {namespace} in order to embed the current namespace in references, strings, etc.

This was accomplished by adding support for parsing expanded values in the loader. Whenever a property value is enclosed in back-quotes, it is parsed so that any text enclosed in curly braces within it is expanded in the context of the object being loaded. See Expanded values in Creating GLM Files.

Example
The following will include the namespace in the object's name:
 namespace myspace {
   object myobj {
     name `{namespace}_myobj`;
   };
 };


Groups

[To do]

Group references and object search criteria can refer to name spaces using the FT_NAMESPACE search criteria or the search string namespace=[name]. If nested name spaces are, the search must match the entire path exactly to be included, e.g., namespace=PartA:PartB:PartC.