LCOV - code coverage report
Current view: top level - Core/OXPVerifier - OOOXPVerifierStage.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 6 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOOXPVerifierStage.m
       4             : 
       5             : 
       6             : Copyright (C) 2007-2013 Jens Ayton
       7             : 
       8             : Permission is hereby granted, free of charge, to any person obtaining a copy
       9             : of this software and associated documentation files (the "Software"), to deal
      10             : in the Software without restriction, including without limitation the rights
      11             : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      12             : copies of the Software, and to permit persons to whom the Software is
      13             : furnished to do so, subject to the following conditions:
      14             : 
      15             : The above copyright notice and this permission notice shall be included in all
      16             : copies or substantial portions of the Software.
      17             : 
      18             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      19             : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      20             : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      21             : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      22             : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      23             : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      24             : SOFTWARE.
      25             : 
      26             : */
      27             : 
      28             : #include <assert.h>
      29             : 
      30             : #import "OOOXPVerifierStageInternal.h"
      31             : 
      32             : #if OO_OXP_VERIFIER_ENABLED
      33             : 
      34             : @interface OOOXPVerifierStage (OOPrivate)
      35             : 
      36           0 : - (void)registerDepedent:(OOOXPVerifierStage *)dependent;
      37           0 : - (void)dependencyCompleted:(OOOXPVerifierStage *)dependency;
      38             : 
      39             : @end
      40             : 
      41             : 
      42             : @implementation OOOXPVerifierStage
      43             : 
      44           0 : - (id)init
      45             : {
      46             :         self = [super init];
      47             :         
      48             :         if (self != nil)
      49             :         {
      50             :                 _dependencies = [[NSMutableSet alloc] init];
      51             :                 _incompleteDependencies = [[NSMutableSet alloc] init];
      52             :                 _dependents = [[NSMutableSet alloc] init];
      53             :                 _canRun = NO;
      54             :         }
      55             :         
      56             :         return self;
      57             : }
      58             : 
      59             : 
      60           0 : - (void)dealloc
      61             : {
      62             :         [_dependencies release];
      63             :         [_incompleteDependencies release];
      64             :         [_dependents release];
      65             :         
      66             :         [super dealloc];
      67             : }
      68             : 
      69             : 
      70           0 : - (id)description
      71             : {
      72             :         return [NSString stringWithFormat:@"<%@ %p>{\"%@\"}", [self class], self, [self name]];
      73             : }
      74             : 
      75             : 
      76             : - (OOOXPVerifier *)verifier
      77             : {
      78             :         return [[_verifier retain] autorelease];
      79             : }
      80             : 
      81             : 
      82             : - (BOOL)completed
      83             : {
      84             :         return _hasRun;
      85             : }
      86             : 
      87             : 
      88             : - (NSString *)name
      89             : {
      90             :         OOLogGenericSubclassResponsibility();
      91             :         return nil;
      92             : }
      93             : 
      94             : 
      95             : - (NSSet *)dependencies
      96             : {
      97             :         return nil;
      98             : }
      99             : 
     100             : 
     101             : - (NSSet *)dependents
     102             : {
     103             :         return nil;
     104             : }
     105             : 
     106             : 
     107             : - (BOOL)shouldRun
     108             : {
     109             :         return YES;
     110             : }
     111             : 
     112             : 
     113             : - (void)run
     114             : {
     115             :         OOLogGenericSubclassResponsibility();
     116             : }
     117             : 
     118             : @end
     119             : 
     120             : 
     121             : @implementation OOOXPVerifierStage (OOInternal)
     122             : 
     123             : - (void)setVerifier:(OOOXPVerifier *)verifier
     124             : {
     125             :         _verifier = verifier;   // Not retained.
     126             : }
     127             : 
     128             : 
     129             : - (BOOL)isDependentOf:(OOOXPVerifierStage *)stage
     130             : {
     131             :         NSEnumerator                    *directDepEnum = nil;
     132             :         OOOXPVerifierStage              *directDep = nil;
     133             :         
     134             :         if (stage == nil)  return NO;
     135             :         
     136             :         // Direct dependency check.
     137             :         if ([_dependencies containsObject:stage])  return YES;
     138             :         
     139             :         // Recursive dependency check.
     140             :         for (directDepEnum = [_dependencies objectEnumerator]; (directDep = [directDepEnum nextObject]); )
     141             :         {
     142             :                 if ([directDep isDependentOf:stage])  return YES;
     143             :         }
     144             :         
     145             :         return NO;
     146             : }
     147             : 
     148             : 
     149             : - (void)registerDependency:(OOOXPVerifierStage *)dependency
     150             : {
     151             :         [_dependencies addObject:dependency];
     152             :         [_incompleteDependencies addObject:dependency];
     153             :         
     154             :         [dependency registerDepedent:self];
     155             : }
     156             : 
     157             : 
     158             : - (BOOL)canRun
     159             : {
     160             :         return _canRun;
     161             : }
     162             : 
     163             : 
     164             : - (void)performRun
     165             : {
     166             :         assert(_canRun && !_hasRun);
     167             :         
     168             :         OOLogPushIndent();
     169             :         @try
     170             :         {
     171             :                 [self run];
     172             :         }
     173             :         @catch (NSException *exception)
     174             :         {
     175             :                 OOLog(@"verifyOXP.exception", @"***** Exception while running verification stage \"%@\": %@", [self name], exception);
     176             :         }
     177             :         OOLogPopIndent();
     178             :         
     179             :         _hasRun = YES;
     180             :         _canRun = NO;
     181             :         [_dependents makeObjectsPerformSelector:@selector(dependencyCompleted:) withObject:self];
     182             : }
     183             : 
     184             : 
     185             : - (void)noteSkipped
     186             : {
     187             :         assert(_canRun && !_hasRun);
     188             :         
     189             :         _hasRun = YES;
     190             :         _canRun = NO;
     191             :         [_dependents makeObjectsPerformSelector:@selector(dependencyCompleted:) withObject:self];
     192             : }
     193             : 
     194             : 
     195             : - (void)dependencyRegistrationComplete
     196             : {
     197             :         _canRun = [_incompleteDependencies count] == 0;
     198             : }
     199             : 
     200             : 
     201             : - (NSSet *)resolvedDependencies
     202             : {
     203             :         return _dependencies;
     204             : }
     205             : 
     206             : 
     207             : - (NSSet *)resolvedDependents
     208             : {
     209             :         return _dependents;
     210             : }
     211             : 
     212             : @end
     213             : 
     214             : 
     215             : @implementation OOOXPVerifierStage (OOPrivate)
     216             : 
     217             : - (void)registerDepedent:(OOOXPVerifierStage *)dependent
     218             : {
     219             :         assert(![self isDependentOf:dependent]);
     220             :         
     221             :         [_dependents addObject:dependent];
     222             : }
     223             : 
     224             : 
     225             : - (void)dependencyCompleted:(OOOXPVerifierStage *)dependency
     226             : {
     227             :         [_incompleteDependencies removeObject:dependency];
     228             :         if ([_incompleteDependencies count] == 0)  _canRun = YES;
     229             : }
     230             : 
     231             : @end
     232             : 
     233             : #endif  //OO_OXP_VERIFIER_ENABLED

Generated by: LCOV version 1.14