/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to setups/katrin/classes/kdbrunidentifier.php

  • Committer: Suren A. Chilingaryan
  • Date: 2014-01-25 16:38:03 UTC
  • Revision ID: csa@dside.dyndns.org-20140125163803-mhmpyk4dpzz7qabw
Detach setups

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
// $Id: kdbrunidentifier.php 8097 2010-07-15 09:57:24Z s_voec01 $
3
 
// Author: Sebastian Voecking <sebastian.voecking@uni-muenster.de>
4
 
 
5
 
ADEI::RequireClass('KDBConstants', TRUE);
6
 
 
7
 
class KDBRunIdentifier
8
 
{
9
 
    public $system = kSystemInvalid;
10
 
    public $number = 0;
11
 
    public $subRun = 0;
12
 
    
13
 
    function __construct()
14
 
    {
15
 
        if (func_num_args() == 1 && is_string(func_get_arg(0))) {
16
 
            $this->ParseString(func_get_arg(0));
17
 
        }
18
 
        else {
19
 
            if (func_num_args() >= 1) {
20
 
                $this->system = func_get_arg(0);
21
 
            }
22
 
            if (func_num_args() >= 2) {
23
 
                $this->number = func_get_arg(1);
24
 
            }
25
 
            if (func_num_args() >= 3) {
26
 
                $this->subRun = func_get_arg(2);
27
 
            }
28
 
        }
29
 
    }
30
 
 
31
 
    function GetRun()
32
 
    {
33
 
        return $this->number;
34
 
    }
35
 
 
36
 
    function GetSubRun()
37
 
    {
38
 
        return $this->subRun;
39
 
    }
40
 
 
41
 
    function SetSubRun($subrun)
42
 
    {
43
 
        $this->subRun = $subrun;
44
 
    }
45
 
 
46
 
    function GetSystem()
47
 
    {
48
 
        return $this->system;
49
 
    }
50
 
 
51
 
    function GetRunName()
52
 
    {
53
 
        return sprintf("%s%08d", $this->GetSystemName(), $this->number);
54
 
    }
55
 
 
56
 
    function GetName()
57
 
    {
58
 
        $name = $this->GetRunName();
59
 
        if ($this->subRun != 0) {
60
 
            $name .= sprintf(".%05d", $this->subRun);
61
 
        }
62
 
 
63
 
        return $name;
64
 
    }
65
 
 
66
 
    function IsValid()
67
 
    {
68
 
        return $this->system != kSystemInvalid && $this->number != 0;
69
 
    }
70
 
 
71
 
    private function ParseString($text)
72
 
    {
73
 
        $pattern = '=^(?<system>[a-z]+)(?<run>\d+)(\.(?<subrun>\d+))?=';
74
 
        
75
 
        if (preg_match($pattern, $text, $matches)) {
76
 
            try {
77
 
                $this->system =
78
 
                    KDBConstants::OrcaSystemValue($matches['system']);
79
 
            }
80
 
            catch (ADEIException $e) {
81
 
                $this->system = kSystemInvalid;
82
 
            }
83
 
            
84
 
            $this->number = (int) $matches['run'];
85
 
            if (array_key_exists('subrun', $matches)) {
86
 
                $this->subRun = (int) $matches['subrun'];
87
 
            }
88
 
        }
89
 
    }
90
 
 
91
 
    private function GetSystemName()
92
 
    {
93
 
        return KDBConstants::OrcaSystemName($this->system);
94
 
    }
95
 
}
96
 
?>
 
 
b'\\ No newline at end of file'