relation_set.cc
//determines the relation set size and directly processes the relations s.t. their structure is stored in a vector 
//returns the starting offset of the variable set
//can't directly evaluate the relations, since we dont't now the starting offset of the variable set before we determine it
//the relations set size
determines the relation set size and directly processes the relations s.t. their structure is stored in a vector
returns the starting offset of the variable set
can't directly evaluate the relations, since we dont't now the starting offset of the variable set before we determine it
the relations set size
determines the relation set size and directly processes the relations s . t . their structure is stored in a vector returns the starting offset of the variable set can ' t directly evaluate the relations since we dont ' t now the starting offset of the variable set before we determine it the relations set size
void RelationSet::parse(uint64_t relationSetOffset, uint64_t numberOfRelations)  {
    uint32_t variableCounter = 0;
    relations.clear(); 
    policyBinary.setPosition(relationSetOffset);
    for(uint16_t relId = 0; relId < numberOfRelations; relId++)  {
        uint8_t numberOfElements = 2; 
        Relation relation;
        #if OPTIMIZE_NEXT_RELATION_EQUATION_OCCURENCES
            uint64_t compressedBit = policyBinary.next(1);
            if(compressedBit == 0)  {
                relation.type = RelationSetType::EQUAL;
                #if DEBUG_POLICY_EVALUATION
                    cout << "Compressed Relation: " << uintToString(relationTypeToInt[relation.type], bitsForRelationType) << " ";
                #endif
                for(uint16_t elementId = 0; elementId < numberOfElements; elementId++)  { 
                    #if DEBUG_POLICY_EVALUATION
                        cout << "NEXT(" << variableCounter << ") ";
                    #endif
                    relation.variableIds[elementId] = variableCounter;
                    variableCounter++;
                }
            }
            else  {
        #endif
                relation.type = getType(); //get the relation type
                #if DEBUG_POLICY_EVALUATION
                    cout << "Uncompressed Relation: " << uintToString(relationTypeToInt[relation.type], bitsForRelationType) << " ";
                #endif
                if(relation.type == RelationSetType::IS_TRUE || relation.type == RelationSetType::IS_FALSE){
                    numberOfElements = 1;
					relation.variableIds[1] = -2;
				}
                for(uint16_t elementId = 0; elementId < numberOfElements; elementId++)  { 
                    uint64_t firstBit = policyBinary.next(1);
                    if(firstBit == 0)  { 
                        #if DEBUG_POLICY_EVALUATION
                            cout << "NEXT(" << variableCounter << ") ";
                        #endif
                        relation.variableIds[elementId] = variableCounter;
                        variableCounter++; 
                    }
                    else { 
                        if(variableCounter == 0) 
                            throw "Invalid policy binary: SPECIFIC_VARIABLE (allows only to step back) is used before any variable is defined!";
                        const uint64_t specVarId = policyBinary.next(variableSet.bitsForSpecificVariableId);
                        relation.variableIds[elementId] = specVarId;
                        #if DEBUG_POLICY_EVALUATION
                            cout << "SPEC_VAR(" << specVarId << ") ";
                        #endif
                    }
                }
        #if OPTIMIZE_NEXT_RELATION_EQUATION_OCCURENCES
            }
        #endif
        relations.push_back(relation);
        #if DEBUG_POLICY_EVALUATION
            cout << endl;
        #endif
    }
    numberOfVariables = variableCounter;
    variableSetOffset = policyBinary.getPosition(); 
    #if DEBUG_POLICY_GENERATION | DEBUG_POLICY_EVALUATION
        cout << "VariableSetOffset: " << variableSetOffset << endl;
    #endif
}
void RelationSet :: parse ( uint64_t relationSetOffset , uint64_t numberOfRelations ) { uint32_t variableCounter = 0 ; relations . clear ( ) ; policyBinary . setPosition ( relationSetOffset ) ; for ( uint16_t relId = 0 ; relId < numberOfRelations ; relId ++ ) { uint8_t numberOfElements = 2 ; Relation relation ; #if OPTIMIZE_NEXT_RELATION_EQUATION_OCCURENCES uint64_t compressedBit = policyBinary . next ( 1 ) ; if ( compressedBit == 0 ) { relation . type = RelationSetType :: EQUAL ; #if DEBUG_POLICY_EVALUATION cout << " " << uintToString ( relationTypeToInt [ relation . type ] , bitsForRelationType ) << " " ; #endif for ( uint16_t elementId = 0 ; elementId < numberOfElements ; elementId ++ ) { #if DEBUG_POLICY_EVALUATION cout << " " << variableCounter << " " ; #endif relation . variableIds [ elementId ] = variableCounter ; variableCounter ++ ; } } else { #endif 
                relation.type = getType(); //get the relation type #if DEBUG_POLICY_EVALUATION cout << " " << uintToString ( relationTypeToInt [ relation . type ] , bitsForRelationType ) << " " ; #endif if ( relation . type == RelationSetType :: IS_TRUE || relation . type == RelationSetType :: IS_FALSE ) { numberOfElements = 1 ; relation . variableIds [ 1 ] = -2 ; } for ( uint16_t elementId = 0 ; elementId < numberOfElements ; elementId ++ ) { uint64_t firstBit = policyBinary . next ( 1 ) ; if ( firstBit == 0 ) { #if DEBUG_POLICY_EVALUATION cout << " " << variableCounter << " " ; #endif relation . variableIds [ elementId ] = variableCounter ; variableCounter ++ ; } else { if ( variableCounter == 0 ) throw " " ; const uint64_t specVarId = policyBinary . next ( variableSet . bitsForSpecificVariableId ) ; relation . variableIds [ elementId ] = specVarId ; #if DEBUG_POLICY_EVALUATION cout << " " << specVarId << " " ; #endif } } #if OPTIMIZE_NEXT_RELATION_EQUATION_OCCURENCES } #endif relations . push_back ( relation ) ; #if DEBUG_POLICY_EVALUATION cout << endl ; #endif } numberOfVariables = variableCounter ; variableSetOffset = policyBinary . getPosition ( ) ; #if DEBUG_POLICY_GENERATION | DEBUG_POLICY_EVALUATION cout << " " << variableSetOffset << endl ; #endif }
determines the relation set size and directly processes the relations s.t.
determines the relation set size and directly processes the relations s . t .
//ensures that we start a new relation set //go to the start of the relation set //process every relation inside the relation set //normally we have binary relations //if the compressed bit (first bit of a relation) is a 0, the relation is a compressed =, next, next //else with a 1 a normal relation defintion follows //we only have one child, if it's a IS_TRUE or IS_FALSE relation //the second variable will not be used //now get the LHS and RHS for this relation //NEXT_VARIABLE //store the variable position as relation element //since it is a new variable //SPECIFIC_VARIABLE //check that the first relation is not a SPECIFIC one //end position of the relation set is the start of the variable set