company logo

Property :: check - Check property handle

The function checks whether a property handle is valid and opened. When the property is invalid, the function throws an error. In order to check, whether the property handle is valid, one may also call isValid(). After being created, property handles are valid, but not yet accessible.

Usually, property handles are initialized on demand, i.e. when accessing data. After opening a property handle a type definition is available and access is possible in principle. When, however, passing complex operation paths as data source for a property handle, errors will not be detected, as long as the property handle is not being initialized. In this case, the function might be called in order to initialize the property handle explicitly and checking the result. Otherwise, this happens implicitly, e.g. when calling get(), and it might become difficult to recognize the error reason, when the function fails.

When passing true in bInitialize, the function will initialize the property handle, when not yet being initialized.

The function returns true, when the property handle is valid and initialized and false otherwise.

// fragment: ObjectSpace    osh;

  OSIString  operation("Person::GetMarriesUnder20");

  Property   married(osh,operation,read);

  if ( married.check() )

    output(String(married.count()));

  else

    output(operation + " is not valid");

Return value:  Success ( bool  )

The value is true when the function was executed successfully. Otherwise the value is set to false.

Implementation details

bool Property  :: check ( bool bInitialize )
  • bInitialize - Initialization option

    The option indicates, whether initialization is required for the object when not yet being initialized (true) or not (false).