API reference - Class LayerInfo

Notation used in Ruby API documentation

Module: db

Description: A structure encapsulating the layer properties

The layer properties describe how a layer is stored in a GDS2 or OASIS file for example. The LayerInfo object represents the storage properties that are attached to a layer in the database.

In general, a layer has either a layer and a datatype number (in GDS2), a name (for example in DXF or CIF) or both (in OASIS). In the latter case, the primary identification is through layer and datatype number and the name is some annotation attached to it. A LayerInfo object which specifies just a name returns true on is_named?. The LayerInfo object can also specify an anonymous layer (use LayerInfo#new without arguments). Such a layer will not be stored when saving the layout. They can be employed for temporary layers for example. Use LayerInfo#anonymous? to test whether a layer does not have a specification.

The LayerInfo is used for example in Layout#insert_layer to specify the properties of the new layer that will be created. The is_equivalent? method compares two LayerInfo objects using the layer and datatype numbers with a higher priority over the name.

Public constructors

new LayerInfo ptrnewThe default constructor.
new LayerInfo ptrnew(int layer,
int datatype)
The constructor for a layer/datatype pair.
new LayerInfo ptrnew(string name)The constructor for a named layer.
new LayerInfo ptrnew(int layer,
int datatype,
string name)
The constructor for a named layer with layer and datatype.

Public methods

[const]bool!=(const LayerInfo b)Compares two layer info objects
[const]bool==(const LayerInfo b)Compares two layer info objects
void_createEnsures the C++ object is created
void_destroyExplicitly destroys the object
[const]bool_destroyed?Returns a value indicating whether the object was already destroyed
[const]bool_is_const_object?Returns a value indicating whether the reference is a const reference
void_manageMarks the object as managed by the script side.
void_unmanageMarks the object as no longer owned by the script side.
[const]boolanonymous?Returns true, if the layer has no specification (i.e. is created by the default constructor).
voidassign(const LayerInfo other)Assigns another object to self
[const]intdatatypeGets the datatype
voiddatatype=(int datatype)Set the datatype
[const]new LayerInfo ptrdupCreates a copy of self
[const]unsigned longhashComputes a hash value
[const]boolis_equivalent?(const LayerInfo b)Equivalence of two layer info objects
[const]boolis_named?Returns true, if the layer is purely specified by name.
[const]intlayerGets the layer number
voidlayer=(int layer)Sets the layer number
[const]stringnameGets the layer name
voidname=(string name)Set the layer name
[const]stringto_s(bool as_target = false)Convert the layer info object to a string

Public static methods and constants

LayerInfofrom_string(string s,
bool as_target = false)
Create a layer info object from a string

Deprecated methods (protected, public, static, non-static and constructors)

voidcreateUse of this method is deprecated. Use _create instead
voiddestroyUse of this method is deprecated. Use _destroy instead
[const]booldestroyed?Use of this method is deprecated. Use _destroyed? instead
[const]boolis_const_object?Use of this method is deprecated. Use _is_const_object? instead

Detailed description

!=

Signature: [const] bool != (const LayerInfo b)

Description: Compares two layer info objects

Returns:True, if both are not equal

This method was added in version 0.18.

==

Signature: [const] bool == (const LayerInfo b)

Description: Compares two layer info objects

Returns:True, if both are equal

This method was added in version 0.18.

_create

Signature: void _create

Description: Ensures the C++ object is created

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

_destroy

Signature: void _destroy

Description: Explicitly destroys the object

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

_destroyed?

Signature: [const] bool _destroyed?

Description: Returns a value indicating whether the object was already destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

_is_const_object?

Signature: [const] bool _is_const_object?

Description: Returns a value indicating whether the reference is a const reference

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

_manage

Signature: void _manage

Description: Marks the object as managed by the script side.

After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required.

Usually it's not required to call this method. It has been introduced in version 0.24.

_unmanage

Signature: void _unmanage

Description: Marks the object as no longer owned by the script side.

Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur.

Usually it's not required to call this method. It has been introduced in version 0.24.

anonymous?

Signature: [const] bool anonymous?

Description: Returns true, if the layer has no specification (i.e. is created by the default constructor).

Returns:True, if the layer does not have any specification.

This method was added in version 0.23.

assign

Signature: void assign (const LayerInfo other)

Description: Assigns another object to self

create

Signature: void create

Description: Ensures the C++ object is created

Use of this method is deprecated. Use _create instead

Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created.

datatype

Signature: [const] int datatype

Description: Gets the datatype

Python specific notes:
The object exposes a readable attribute 'datatype'. This is the getter.

datatype=

Signature: void datatype= (int datatype)

Description: Set the datatype

Python specific notes:
The object exposes a writable attribute 'datatype'. This is the setter.

destroy

Signature: void destroy

Description: Explicitly destroys the object

Use of this method is deprecated. Use _destroy instead

Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing.

destroyed?

Signature: [const] bool destroyed?

Description: Returns a value indicating whether the object was already destroyed

Use of this method is deprecated. Use _destroyed? instead

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

dup

Signature: [const] new LayerInfo ptr dup

Description: Creates a copy of self

Python specific notes:
This method also implements '__copy__' and '__deepcopy__'.

from_string

Signature: [static] LayerInfo from_string (string s, bool as_target = false)

Description: Create a layer info object from a string

The:string
Returns:The LayerInfo object

If 'as_target' is true, relative specifications such as '*+1' for layer or datatype are permitted.

This method will take strings as produced by to_s and create a LayerInfo object from them. The format is either "layer", "layer/datatype", "name" or "name (layer/datatype)".

This method was added in version 0.23. The 'as_target' argument has been added in version 0.26.5.

hash

Signature: [const] unsigned long hash

Description: Computes a hash value

Returns a hash value for the given layer info object. This method enables layer info objects as hash keys.

This method has been introduced in version 0.25.

Python specific notes:
This method is also available as 'hash(object)'.

is_const_object?

Signature: [const] bool is_const_object?

Description: Returns a value indicating whether the reference is a const reference

Use of this method is deprecated. Use _is_const_object? instead

This method returns true, if self is a const reference. In that case, only const methods may be called on self.

is_equivalent?

Signature: [const] bool is_equivalent? (const LayerInfo b)

Description: Equivalence of two layer info objects

Returns:True, if both are equivalent

First, layer and datatype are compared. The name is of second order and used only if no layer or datatype is given for one of the operands. This is basically a weak comparison that reflects the search preferences. It is the basis for Layout#find_layer. Here are some examples:

# no match as layer/datatypes or names differ:
RBA::LayerInfo::new(1, 17).is_equivalent?(RBA::LayerInfo::new(1, 18)) -> false
RBA::LayerInfo::new('metal1').is_equivalent?(RBA::LayerInfo::new('m1')) -> false
# exact match for numbered or named layers:
RBA::LayerInfo::new(1, 17).is_equivalent?(RBA::LayerInfo::new(1, 17)) -> true
RBA::LayerInfo::new('metal1').is_equivalent?(RBA::LayerInfo::new('metal1')) -> true
# match as names are second priority over layer/datatypes:
RBA::LayerInfo::new(1, 17, 'metal1').is_equivalent?(RBA::LayerInfo::new(1, 17, 'm1')) -> true
# match as name matching is fallback:
RBA::LayerInfo::new(1, 17, 'metal1').is_equivalent?(RBA::LayerInfo::new('metal1')) -> true
# no match as neither names or layer/datatypes match:
RBA::LayerInfo::new(1, 17, 'metal1').is_equivalent?(RBA::LayerInfo::new('m1')) -> false

This method was added in version 0.18 and modified to compare non-named vs. named layers in version 0.28.11.

is_named?

Signature: [const] bool is_named?

Description: Returns true, if the layer is purely specified by name.

Returns:True, if no layer or datatype is given.

This method was added in version 0.18.

layer

Signature: [const] int layer

Description: Gets the layer number

Python specific notes:
The object exposes a readable attribute 'layer'. This is the getter.

layer=

Signature: void layer= (int layer)

Description: Sets the layer number

Python specific notes:
The object exposes a writable attribute 'layer'. This is the setter.

name

Signature: [const] string name

Description: Gets the layer name

Python specific notes:
The object exposes a readable attribute 'name'. This is the getter.

name=

Signature: void name= (string name)

Description: Set the layer name

The name is set on OASIS input for example, if the layer has a name.

Python specific notes:
The object exposes a writable attribute 'name'. This is the setter.

new

(1) Signature: [static] new LayerInfo ptr new

Description: The default constructor.

Creates a default LayerInfo object.

This method was added in version 0.18.

Python specific notes:
This method is the default initializer of the object.

(2) Signature: [static] new LayerInfo ptr new (int layer, int datatype)

Description: The constructor for a layer/datatype pair.

layer:The layer number
datatype:The datatype number

Creates a LayerInfo object representing a layer and datatype.

This method was added in version 0.18.

Python specific notes:
This method is the default initializer of the object.

(3) Signature: [static] new LayerInfo ptr new (string name)

Description: The constructor for a named layer.

name:The name

Creates a LayerInfo object representing a named layer.

This method was added in version 0.18.

Python specific notes:
This method is the default initializer of the object.

(4) Signature: [static] new LayerInfo ptr new (int layer, int datatype, string name)

Description: The constructor for a named layer with layer and datatype.

layer:The layer number
datatype:The datatype number
name:The name

Creates a LayerInfo object representing a named layer with layer and datatype.

This method was added in version 0.18.

Python specific notes:
This method is the default initializer of the object.

to_s

Signature: [const] string to_s (bool as_target = false)

Description: Convert the layer info object to a string

Returns:The string

If 'as_target' is true, wildcard and relative specifications are formatted such such.

This method was added in version 0.18. The 'as_target' argument has been added in version 0.26.5.

Python specific notes:
This method is also available as 'str(object)'.