Archicad 28 C++ API
Loading...
Searching...
No Matches
ACAPI::MEP::v1::ReferenceSetBase Class Reference

The ReferenceSetBase represents a named table, and it contains referenceIds which are used as keys in the PreferenceTables. By default, Archicad will provide you the DN referenceSet, but you can choose your own by renaming it and populate it with your desired values. More...

#include <MEPReferenceSetBase.hpp>

Inheritance diagram for ACAPI::MEP::v1::ReferenceSetBase:
ACAPI::v1::Object ACAPI::MEP::v1::DuctReferenceSet ACAPI::MEP::v1::PipeReferenceSet

Public Member Functions

bool Exists () const
 
Result< void > IsEditable () const
 Checks whether the table is editable.
 
GS::UniString GetName () const
 
uint32_t GetSize () const
 
Result< uint32_t > GetReferenceId (uint32_t index) const
 
Result< bool > IsReferenceIdDefined (uint32_t index) const
 Checks whether an entry from the referenceSet is defined. A referenceId is defined if at least one preferenceTable has values associated to it.
 
template<typename ModifierFunc >
Result< void > Modify (const ModifierFunc &modifierFunc, const GS::UniString &undoString)
 Executes the passed modifier scope in an Undoable command.
 
void SetName (const GS::UniString &referenceSetName)
 Sets the name of the referenceSet.
 
Result< uint32_t > Add (uint32_t id)
 Adds a new referenceId into the referenceSet. If the id is a duplicate, it will not be inserted twice.
 
Result< void > Delete (uint32_t id)
 Deletes an entry from the referenceSet. Only undefined referenceIds can be deleted. A referenceId is defined if at least one preferenceTable has values associated to it.
 
- Public Member Functions inherited from ACAPI::v1::Object
 Object (std::shared_ptr< Impl::ObjectImpl > impl)
 Constructs a new object.
 
const API_TokenGetToken () const
 Get the token for this object.
 

Protected Member Functions

 ReferenceSetBase (std::shared_ptr< Impl::IReferenceSetBaseImpl > impl)
 Constructs a ReferenceSetBase with the given base implementation.
 
 Modifier (ReferenceSetBase &parent)
 Constructs a Modifier with the given referenceSetBase.
 
- Protected Member Functions inherited from ACAPI::v1::Object
 ~Object ()
 Default destructor.
 

Additional Inherited Members

- Protected Attributes inherited from ACAPI::v1::Object
std::shared_ptr< Impl::ObjectImplmImpl
 Impl object given by constructor.
 

Detailed Description

The ReferenceSetBase represents a named table, and it contains referenceIds which are used as keys in the PreferenceTables. By default, Archicad will provide you the DN referenceSet, but you can choose your own by renaming it and populate it with your desired values.

Since
Archicad 28

The entries of the set have to be unique and are always in ascending order. Entries that are defined in PreferenceTables cannot be deleted.

Example code snippet from Test / New MEP
Getters
if (ductReferenceSet.IsErr ())
return ductReferenceSet.UnwrapErr ().kind;
preferenceReporter.Add ("Duct Preferences");
preferenceReporter.AddNewLine ();
preferenceReporter.SetTabCount (1);
preferenceReporter.Add ("Duct Reference Set");
uint32_t referenceIdCount = ductReferenceSet->GetSize ();
preferenceReporter.SetTabCount (2);
for (uint32_t i = 0; i < referenceIdCount; ++i) {
preferenceReporter.Add ("ReferenceId", *ductReferenceSet->GetReferenceId (i));
}
Result is the standard return type of API functions.
Definition: Result.hpp:845
E UnwrapErr() const
Unwraps the error value contained in the Result. Trying to UnwrapErr the value while it contains an O...
Definition: Result.hpp:1140
bool IsErr() const
Definition: Result.hpp:945
Result< DuctReferenceSet > GetDuctReferenceSet()
Definition: MEPDuctReferenceSet.hpp:34
Modification
Reporter preferenceReporter;
if (referenceSet.IsErr ())
return referenceSet.UnwrapErr ().kind;
// SetName
preferenceReporter.Add ("Renaming the Reference Set...");
referenceSet->Modify ([&] (ACAPI::MEP::ReferenceSetBase::Modifier& modifier) {
modifier.SetName ("Not DN");
}, "Modify the name of Reference Set.");
// Addition
preferenceReporter.Add ("Adding new ReferenceIds to the Reference Set...");
referenceSet->Modify ([&] (ReferenceSetBase::Modifier& modifier) {
const auto& Add = ([&] (UInt32 referenceId)
{
preferenceReporter.Add ("Trying to add " + GS::ValueToUniString (referenceId));
ACAPI::Result<uint32_t> addRes = modifier.Add (referenceId);
if (addRes.IsOk ())
preferenceReporter.Add ("ReferenceId successfully added!");
else
preferenceReporter.Add (GS::UniString (addRes.UnwrapErr ().text));
});
Add (110);
Add (700);
Add (1000);
}, "Add new values to the Reference Set.");
// Deletion
const auto ReportDeletion = [&] (const ACAPI::Result<void>& deletionResult) {
if (deletionResult.IsOk ())
preferenceReporter.Add ("Deletion was successful.");
else
preferenceReporter.Add ("Deletion unsuccessful", GS::UniString (deletionResult.UnwrapErr ().text));
};
// Deleting an unused ReferenceId
preferenceReporter.Add ("Deleting ReferenceId 400, which is unused");
referenceSet->Modify ([&] (ACAPI::MEP::ReferenceSetBase::Modifier& modifier) {
ACAPI::Result<void> res = modifier.Delete (400);
ReportDeletion (res);
}, "Delete an unused value from the Reference Set.");
Modifier(ReferenceSetBase &parent)
Constructs a Modifier with the given referenceSetBase.
Result< uint32_t > Add(uint32_t id)
Adds a new referenceId into the referenceSet. If the id is a duplicate, it will not be inserted twice...
bool IsOk() const
Definition: Result.hpp:940
Result< PipeReferenceSet > GetPipeReferenceSet()
Definition: MEPPipeReferenceSet.hpp:34

Constructor & Destructor Documentation

◆ ReferenceSetBase()

ACAPI::MEP::v1::ReferenceSetBase::ReferenceSetBase ( std::shared_ptr< Impl::IReferenceSetBaseImpl >  impl)
protected

Constructs a ReferenceSetBase with the given base implementation.

Parameters
implThe given base implementation.

Member Function Documentation

◆ Add()

Result< uint32_t > ACAPI::MEP::v1::ReferenceSetBase::Add ( uint32_t  id)

Adds a new referenceId into the referenceSet. If the id is a duplicate, it will not be inserted twice.

Parameters
idThe id to be added.
Returns
Returns error if the referenceId is a duplicate, otherwise returns the index of the referenceId in the referenceSet.

◆ Delete()

Result< void > ACAPI::MEP::v1::ReferenceSetBase::Delete ( uint32_t  id)

Deletes an entry from the referenceSet. Only undefined referenceIds can be deleted. A referenceId is defined if at least one preferenceTable has values associated to it.

Parameters
idThe id to be deleted.
Returns
Returns error if the id cannot be deleted due to reasons mentioned above, otherwise nothing.

◆ Exists()

bool ACAPI::MEP::v1::ReferenceSetBase::Exists ( ) const
Returns
Checks if the object still exists.

◆ GetName()

GS::UniString ACAPI::MEP::v1::ReferenceSetBase::GetName ( ) const
Returns
Returns the name of the referenceSet.

◆ GetReferenceId()

Result< uint32_t > ACAPI::MEP::v1::ReferenceSetBase::GetReferenceId ( uint32_t  index) const
Parameters
indexThe index of the row. Index starts from 0.
Returns
Returns the referenceId of the row identified by index.

◆ GetSize()

uint32_t ACAPI::MEP::v1::ReferenceSetBase::GetSize ( ) const
Returns
Returns the size of the referenceSet.

◆ IsEditable()

Result< void > ACAPI::MEP::v1::ReferenceSetBase::IsEditable ( ) const

Checks whether the table is editable.

Returns
Returns nothing if the table is editable, otherwise the error code and error message containing information about the reason.

◆ IsReferenceIdDefined()

Result< bool > ACAPI::MEP::v1::ReferenceSetBase::IsReferenceIdDefined ( uint32_t  index) const

Checks whether an entry from the referenceSet is defined. A referenceId is defined if at least one preferenceTable has values associated to it.

Parameters
indexThe index of the row. Index starts from 0.
Returns
Returns whether the row identified by index is defined.

◆ Modifier()

ACAPI::MEP::v1::ReferenceSetBase::Modifier ( ReferenceSetBase parent)
protected

Constructs a Modifier with the given referenceSetBase.

Parameters
parentThe given parent ReferenceSetBase.

◆ Modify()

template<typename ModifierFunc >
Result< void > ACAPI::MEP::v1::ReferenceSetBase::Modify ( const ModifierFunc &  modifierFunc,
const GS::UniString &  undoString 
)

Executes the passed modifier scope in an Undoable command.

Parameters
modifierFuncThe modifier scope (lambda, std::function or function pointer) the caller wants to execute.
undoStringThe text which appears in the undo queue of Archicad after executing the command.
Returns
Returns an error if the process of modification fails for some reason, otherwise nothing.

◆ SetName()

void ACAPI::MEP::v1::ReferenceSetBase::SetName ( const GS::UniString &  referenceSetName)

Sets the name of the referenceSet.

Parameters
referenceSetNameThe name to be set.