//
//  Created by Ivano Bilenchi on 07/02/18.
//  Copyright © 2018-2020 SisInf Lab. All rights reserved.
//

#import <Foundation/Foundation.h>

@class TMEAtomicConcept;
@class TMECardinalityRole;
@class TMEUniversalRole;

@protocol OWLClass;
@protocol OWLObjectProperty;

NS_ASSUME_NONNULL_BEGIN

/**
 * This class models an ALN concept expression as the conjunction of CCN, CGT, CLT, C∀ components,
 * stored in collections of AtomicConcept, CardinalityRole and UniversalRole class instances.
 *
 * Instances of this class are backed by native data structures, and as such they require
 * special treatment for memory management, therefore they can only be created via the
 * DataFactory instance held by the reasoner (which automatically ties their lifecycle
 * to that of the enclosing objects).
 *
 * Unless otherwise stated, SemanticDescription objects returned by the reasoner
 * instance should not be mutated unless they have been copied beforehand, otherwise
 * an exception is thrown.
 *
 * @see `TMEDataFactory`
 */
@interface TMESemanticDescription : NSObject <NSCopying>

#pragma mark - Properties

/// Atomic concept conjuncts referenced in this description.
@property (nonatomic, copy, readonly) NSArray<TMEAtomicConcept *> * _Nullable atomicConcepts;

/// Negated atomic concept conjuncts referenced in this description.
@property (nonatomic, copy, readonly) NSArray<TMEAtomicConcept *> * _Nullable negatedConcepts;

/// Minimum cardinality restriction conjuncts referenced in this description.
@property (nonatomic, copy, readonly) NSArray<TMECardinalityRole *> * _Nullable greaterThanRoles;

/// Maximum cardinality restriction conjuncts referenced in this description.
@property (nonatomic, copy, readonly) NSArray<TMECardinalityRole *> * _Nullable lessThanRoles;

/// Value restriction conjuncts referenced in this description.
@property (nonatomic, copy, readonly) NSArray<TMEUniversalRole *> * _Nullable universalRoles;

/// :nodoc:
- (instancetype)init UNAVAILABLE_ATTRIBUTE;

/**
 * Adds the specified atomic concept to this description.
 *
 * @param atomicConcept Concept to add.
 */
- (void)addAtomicConcept:(TMEAtomicConcept *)atomicConcept;

/**
 * Adds the atomic concept representing the specified OWL class to this description.
 *
 * @param owlClass Class representing the concept.
 */
- (void)addAtomicConceptWithOwlClass:(id<OWLClass>)owlClass;

/**
 * Adds the specified atomic concepts to this description.
 *
 * @param atomicConcepts Concepts to add.
 */
- (void)addAtomicConcepts:(NSArray<TMEAtomicConcept *> *)atomicConcepts;

/**
 * Adds the specified negated concept to this description.
 *
 * @param negatedConcept Negated concept to add.
 */
- (void)addNegatedConcept:(TMEAtomicConcept *)negatedConcept;

/**
 * Adds the negated concept representing the complement of
 * the specified OWL class to this description.
 *
 * @param owlClass Class representing the concept.
 */
- (void)addNegatedConceptWithOwlClass:(id<OWLClass>)owlClass;

/**
 * Adds the specified negated concepts to this description.
 *
 * @param negatedConcepts Negated concepts to add.
 */
- (void)addNegatedConcepts:(NSArray<TMEAtomicConcept *> *)negatedConcepts;

/**
 * Adds the specified minimum cardinality restriction to this description.
 *
 * @param greaterThanRole Minimum cardinality restriction to add.
 */
- (void)addGreaterThanRole:(TMECardinalityRole *)greaterThanRole;

/**
 * Creates and adds a new minimum cardinality restriction to this description.
 *
 * @param property Property of the restriction.
 * @param cardinality Cardinality of the restriction.
 */
- (void)addGreaterThanRoleWithProperty:(id<OWLObjectProperty>)property
                           cardinality:(NSUInteger)cardinality;

/**
 * Adds the specified minimum cardinality restrictions to this description.
 *
 * @param greaterThanRoles Minimum cardinality restrictions to add.
 */
- (void)addGreaterThanRoles:(NSArray<TMECardinalityRole *> *)greaterThanRoles;

/**
 * Adds the specified maximum cardinality restriction to this description.
 *
 * @param lessThanRole Maximum cardinality restriction to add.
 */
- (void)addLessThanRole:(TMECardinalityRole *)lessThanRole;

/**
 * Creates and adds a new maximum cardinality restriction to this description.
 *
 * @param property Property of the restriction.
 * @param cardinality Cardinality of the restriction.
 */
- (void)addLessThanRoleWithProperty:(id<OWLObjectProperty>)property
                        cardinality:(NSUInteger)cardinality;

/**
 * Adds the specified maximum cardinality restrictions to this description.
 *
 * @param lessThanRoles Maximum cardinality restrictions to add.
 */
- (void)addLessThanRoles:(NSArray<TMECardinalityRole *> *)lessThanRoles;

/**
 * Adds the specified value restriction to this description.
 *
 * @param universalRole Value restriction to add.
 */
- (void)addUniversalRole:(TMEUniversalRole *)universalRole;

/**
 * Creates and adds a new value restriction to this description.
 *
 * @param property Property of the restriction.
 * @param filler Filler of the restriction.
 */
- (void)addUniversalRoleWithProperty:(id<OWLObjectProperty>)property
                              filler:(TMESemanticDescription *)filler;

/**
 * Adds the specified value restrictions to this description.
 *
 * @param universalRoles Value restrictions to add.
 */
- (void)addUniversalRoles:(NSArray<TMEUniversalRole *> *)universalRoles;

/**
 * Performs the intersection between this description and another.
 * Only the current instance is mutated.
 *
 * @param description Description to perform the intersection with.
 */
- (void)intersectWithDescription:(TMESemanticDescription *)description;

@end

NS_ASSUME_NONNULL_END
