~gz/ubuntu/wily/steam/new_rel_udev_rules

« back to all changes in this revision

Viewing changes to server/libraries/Visconte.pmod/Onto.pmod/OWLContainer.pike

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/**
3
 
 * <p>Class OWLContainer - A Container item that holds different OWLItems</p>
4
 
 */
5
 
 
6
 
 
7
 
/**
8
 
 * <p>flag for type equivalence</p>
9
 
 */
10
 
    public constant is_container=1; 
11
 
 
12
 
/**
13
 
 * <p>The iterator for this container</p>
14
 
 */
15
 
    private int iterator = -1;
16
 
   
17
 
/**
18
 
 * <p>the array  holding the OWLItems</p>
19
 
 */
20
 
    public array container = ({});
21
 
 
22
 
 
23
 
/**
24
 
 * <p>Add a OWLItem to this container</p>
25
 
 * 
26
 
 * 
27
 
 * @param item  - OWLItem to add
28
 
 */
29
 
    public void add(Visconte.Onto.Item.OWLItem owlitem) {        
30
 
            container+=({owlitem});
31
 
            iterator=0;
32
 
    } 
33
 
 
34
 
/**
35
 
 * <p>Returns the next OWLItem in the container and pushes the iterator</p>
36
 
 * 
37
 
 * 
38
 
 * @return OWLItem - which comes next
39
 
 */
40
 
    public Visconte.Onto.Item.OWLItem next() 
41
 
    {        
42
 
         Visconte.Onto.Item.OWLItem current_item; 
43
 
         if(iterator>=0 && iterator <sizeof(container))
44
 
         {
45
 
                current_item = container[iterator];
46
 
                iterator++;
47
 
         }
48
 
         else
49
 
         {
50
 
                iterator=0;
51
 
                current_item = container[iterator];
52
 
                iterator++;
53
 
         }
54
 
         
55
 
        return  current_item;
56
 
                
57
 
    } 
58
 
 
59
 
/**
60
 
 * <p>Checks if the container has more items</p>
61
 
 * 
62
 
 * 
63
 
 * @return 
64
 
 */
65
 
    public int has_items() 
66
 
    {        
67
 
         if(iterator>=0 && iterator <sizeof(container))
68
 
         {
69
 
                 return 1;
70
 
         }
71
 
         else
72
 
         {
73
 
                 return 0;
74
 
         }
75
 
    } 
76
 
 
77
 
    
78
 
/**
79
 
 * <p>Find a OWLItem in the container</p>
80
 
 * @param id - the id of the owlitem to find
81
 
 * 
82
 
 * @return OWLItem
83
 
 */
84
 
    public Visconte.Onto.Item.OWLItem find_by_id(string id) 
85
 
    {  
86
 
        Visconte.Onto.Item.OWLItem item; 
87
 
        foreach (container,Visconte.Onto.Item.OWLItem tmp_item)
88
 
        {
89
 
                if(tmp_item->get_Id()==id)
90
 
                {
91
 
                        item = tmp_item;
92
 
                        break;
93
 
                }
94
 
        }
95
 
        return item;
96
 
    }
97
 
    
98
 
    
99
 
/**
100
 
 * <p>Prints a String with the content of the container</p>
101
 
 * 
102
 
 * 
103
 
 * @return the string dump
104
 
 */
105
 
    public string to_string() 
106
 
    {
107
 
            string content ="\nContent of OWLContainer:\n";
108
 
            foreach(container,Visconte.Onto.Item.OWLItem i)
109
 
                    content+="\nItem id:"+i->get_Id()+", label:"+i->get_Label();
110
 
            
111
 
            return content+"\n";
112
 
    }
113
 
 
114
 
 
115
 
/**
116
 
 * <p>Return the size of the container</p>
117
 
 * 
118
 
 * 
119
 
 * @return size as int
120
 
 */
121
 
    public int size_of() 
122
 
    {
123
 
            return sizeof(container);
124
 
    }
125
 
 
126
 
/**
127
 
 * <p>Resets the iterator manuall</p>
128
 
 * 
129
 
 * 
130
 
 * @return 
131
 
 */
132
 
    public void reset_iterator() 
133
 
    {
134
 
            if(sizeof(container)>0)
135
 
                   iterator=0;
136
 
            else
137
 
                   iterator=-1;
138
 
    }
139
 
    
140
 
/**
141
 
 * <p>merges another OWLContainer with this one. Duplicates will be ommited </p>
142
 
 * @param merge_container - the OWLContainer to merge
143
 
 * 
144
 
 * @return succes
145
 
 */
146
 
    public int merge(object merge_container) 
147
 
    {    
148
 
            
149
 
            if(merge_container && merge_container->is_container)
150
 
            { 
151
 
                    foreach(merge_container->container,Visconte.Onto.Item.OWLItem tmp_item)
152
 
                    {
153
 
                            if(!find_by_id(tmp_item->get_Id()))
154
 
                                    container+=({tmp_item});
155
 
                    }
156
 
                    return 1;
157
 
            }
158
 
            else
159
 
                    return 0;
160
 
    }
161
 
    
162
 
    
163
 
    
164
 
    
165