File: AggregateState.m

package info (click to toggle)
paje.app 1.98-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,428 kB
  • sloc: objc: 24,517; ansic: 6,998; makefile: 134; sh: 42; java: 31
file content (60 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "AggregateState.h"

#include "../General/Macros.h"

@implementation AggregateState

+ (PajeEntity *)entityWithEntities:(NSArray *)entities
{
    return [[[self alloc] initWithEntities:entities] autorelease];
}

- (id)initWithEntities:(NSArray *)entities
{
    NSEnumerator *entityEnum;
    PajeEntity *entity;
    PajeEntity *lastEntity;
    
    entityEnum = [entities reverseObjectEnumerator];
    entity = [entityEnum nextObject];

    NSParameterAssert(entity != nil);

    self = [super initWithType:[entity entityType]
                          name:@"AggregateState"
                     container:[entity container]];
    if (self != nil) {
        condensedArray = [[CondensedEntitiesArray alloc] init];
        imbricationLevel = [entity imbricationLevel];
        Assign(endTime, [entity endTime]);
        do {
            [condensedArray addArray:[entity condensedEntities]];
            condensedEntitiesCount += [entity condensedEntitiesCount];
            if (![entity isAggregate]) {
                [condensedArray addValue:[entity value]
                                duration:[entity exclusiveDuration]];
                condensedEntitiesCount ++;
            }
            lastEntity = entity;
        } while ((entity = [entityEnum nextObject]) != nil);
        Assign(startTime, [lastEntity startTime]);
    }
    return self;
}

- (double)subDurationAtIndex:(unsigned)i
{
    return [condensedArray durationAtIndex:i];
}

- (double)exclusiveDuration
{
    return [self duration] - [condensedArray totalDuration];
}

- (int)imbricationLevel
{
    return imbricationLevel;
}

@end