Class Section

Inheritance Relationships

Base Type

Class Documentation

class Section : public nix::base::NamedEntity<base::ISection>

Public Functions

Section()

Constructor that creates an uninitialized Section.

Calling any method on an uninitialized section will throw a nix::UninitializedEntity exception. The following code illustrates how to check if a section is initialized:

Section e = ...;
if (e) {
    // e is initialised
} else {
    // e is uninitialized
}

Section(std::nullptr_t ptr)

Constructor that creates a null Section.

Section(const Section &other)

Copy constructor.

Copying of all NIX front facing objects like Section is a rather cheap operation. Semantically this is equivalent to the creation of another reference to the original object.

Parameters

other – The Section to copy.

Section(const std::shared_ptr<base::ISection> &p_impl)

Constructor that creates a new Section from a shared pointer to an implementation instance.

This constructor should only be used in the back-end.

Section(std::shared_ptr<base::ISection> &&ptr)

Constructor with move semantics that creates a new Section from a shared pointer to an implementation instance.

This constructor should only be used in the back-end.

void repository(const std::string &repository)

Set the repository in which a section of this type is defined.

Usually this information is provided in the form of an URL

Parameters

repository – URL to the repository.

inline boost::optional<std::string> repository() const

Gets the repository URL.

Returns

The URL to the repository.

inline void repository(const boost::none_t t)

Deleter for the repository.

Parameters

t – None

void link(const std::string &id)

Establish a link to another section.

The linking section inherits the properties defined in the linked section. Properties of the same name are overridden.

Parameters

id – The id of the section that should be linked. 1

void link(const Section &link)

Establish a link to another section.

The linking section inherits the properties defined in the linked section. Properties of the same name are overridden.

Parameters

link – The section to link with.

inline Section link() const

Get the linked section.

Returns

The linked section. If no section was linked a null Section will be returned.

inline void link(const boost::none_t t)

Deleter for the linked section.

This just removes the link between both sections, but does not remove the linked section from the file.

Parameters

t – None

inline Section parent() const

Returns the parent section.

Each section which is not a root section has a parent.

Returns

The parent section. If the section has no parent, a null section will be returned.

inline ndsize_t sectionCount() const

Get the number of child section of the section.

Returns

The number of child sections.

inline bool hasSection(const std::string &name_or_id) const

Checks whether a section has a certain child section.

Parameters

name_or_id – Name or id of requested section.

Returns

True if the section is a child, false otherwise.

bool hasSection(const Section &section) const

Checks whether a section has a certain child section.

Parameters

section – The section to check.

Returns

True if the section is a child, false otherwise.

inline Section getSection(const std::string &name_or_id) const

Get a specific child section by its name or id.

Parameters

name_or_id – The name or the ID of the child section.

Returns

The child section.

virtual Section getSection(ndsize_t index) const

Get a child section by its index.

Parameters

index – The index of the child.

Returns

The specified child section.

std::vector<Section> sections(const util::Filter<Section>::type &filter = util::AcceptAll<Section>()) const

Get all direct child sections of the section.

The parameter filter can be used to filter sections by various criteria. By default a filter is used that accepts all sections.

Parameters

filter – A filter function.

Returns

A vector containing the matching child sections.

std::vector<Section> findSections(const util::Filter<Section>::type &filter = util::AcceptAll<Section>(), size_t max_depth = std::numeric_limits<size_t>::max()) const

Get all descendant sections of the section recursively.

This method traverses the sub-tree of all child sections of the section. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.

Parameters
  • filter – A filter function.

  • max_depth – The maximum depth of traversal.

Returns

A vector containing the matching descendant sections.

std::vector<Section> findRelated(const util::Filter<Section>::type &filter = util::AcceptAll<Section>()) const

Find all related sections of the section.

Parameters

filter – A filter function.

Returns

A vector containing all filtered related sections.

Section createSection(const std::string &name, const std::string &type)

Adds a new child section.

Parameters
  • name – The name of the new section

  • type – The type of the section

Returns

The new child section.

inline bool deleteSection(const std::string &name_or_id)

Deletes a section from the section.

Parameters

name_or_id – Name or id of the child section to delete.

Returns

True if the section was deleted, false otherwise.

bool deleteSection(const Section &section)

Deletes a subsection from this Section.

Parameters

section – The section to delete.

Returns

bool successful or not

inline ndsize_t propertyCount() const

Gets the number of properties of this section.

Returns

The number of Properties

inline bool hasProperty(const std::string &name_or_id) const

Checks if a Property with this name/id exists in this Section.

Parameters

name_or_id – Name or id of the property.

Returns

True if the property exists, false otherwise.

bool hasProperty(const Property &property) const

Checks if a Property exists in this Section.

Parameters

property – The Property to check.

Returns

True if the property exists, false otherwise.

inline Property getProperty(const std::string &name_or_id) const

Gets the Property identified by its name or id.

Parameters

name_or_id – Name or id of the property.

Returns

The specified property.

inline Property getProperty(ndsize_t index) const

Gets the property defined by its index.

Parameters

index – The index of the property

Returns

The property.

std::vector<Property> properties(const util::Filter<Property>::type &filter = util::AcceptAll<Property>()) const

Get all properties of the section.

The parameter filter can be used to filter properties by various criteria. By default a filter is used that accepts all properties.

Parameters

filter – A filter function.

Returns

A vector containing the matching properties.

std::vector<Property> inheritedProperties() const

Returns all Properties inherited from a linked section. This list may include Properties that are locally overridden.

Returns

All inherited properties as a vector.

Property createProperty(const std::string &name, const DataType &dtype)

Add a new Property that does not have any Values to this Section.

Parameters
  • name – The name of the property.

  • dtype – The DataType of the property.

Returns

The newly created property

Property createProperty(const std::string &name, const Variant &value)

Add a new Property to the Section.

Parameters
  • name – The name of the property.

  • value – The Value to be stored.

Returns

The newly created property.

Property createProperty(const std::string &name, const std::vector<Variant> &values)

Add a new Property with values to the Section.

Parameters
  • name – The name of the property.

  • values – The values of the created property.

Returns

The newly created property.

inline bool deleteProperty(const std::string &name_or_id)

Delete the Property identified by its name or id.

Parameters

name_or_id – Name or id of the property.

Returns

True if the property was deleted, false otherwise.

bool deleteProperty(const Property &property)

Deletes the Property from this section.

Parameters

property – The Property to delete.

Returns

True if the property was deleted, false otherwise.

std::vector<nix::DataArray> referringDataArrays(const nix::Block &b) const

Find the DataArrays that refer to this Section in the metadata field.

Parameters

b – The Block in which the search should be performed.

Returns

Vector of DataArrays.

std::vector<nix::DataArray> referringDataArrays() const

Find the DataArrays that refer to this Section in the metadata field. Search is performed in the whole file.

Returns

Vector of DataArrays.

std::vector<nix::Tag> referringTags() const

Find the Tags that refer to this Section in the metadata field. Search is performed in the whole file.

Returns

std::vector of Tags.

std::vector<nix::Tag> referringTags(const nix::Block &b) const

Find the Tags that refer to this Section in the metadata field.

Parameters

b – The Block in which the search should be performed.

Returns

std::vector of Tags.

std::vector<nix::MultiTag> referringMultiTags() const

Find the DataArrays that refer to this Section in the metadata field. Search is performed in the whole file.

Returns

std::vector of MultiTags.

std::vector<nix::MultiTag> referringMultiTags(const nix::Block &b) const

Find the MultiTags that refer to this Section in the metadata field.

Parameters

b – The Block in which the search should be performed.

Returns

std::vector of MultiTags.

std::vector<nix::Source> referringSources() const

Find the Sources that refer to this Section in the metadata field.

Returns

std::vector of Sources.

std::vector<nix::Source> referringSources(const nix::Block &b) const

Find the Sources that refer to this Section in the metadata field.

Parameters

b – The nix::Block to which the search should be restricted.

Returns

std::vector of Sources.

std::vector<nix::Block> referringBlocks() const

Find the Blocks that refer to this Section in the metadata field.

Returns

std::vector of Blocks.

inline Section &operator=(const none_t &t)

Assignment operator for none.

inline Section &operator=(const Section &other)

Copy-assignment operator.

Friends

friend NIXAPI friend std::ostream & operator<< (std::ostream &out, const Section &ent)

Output operator.