File: sort_IntegerContainer_Impl.cc

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (180 lines) | stat: -rw-r--r-- 5,637 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// 
// File:          sort_IntegerContainer_Impl.cc
// Symbol:        sort.IntegerContainer-v0.1
// Symbol Type:   class
// Babel Version: 0.10.2
// Description:   Server-side implementation for sort.IntegerContainer
// 
// WARNING: Automatically generated; only changes within splicers preserved
// 
// babel-version = 0.10.2
// 
#include "sort_IntegerContainer_Impl.hh"

// 
// Includes for all method dependencies.
// 
#ifndef included_sidl_BaseInterface_hh
#include "sidl_BaseInterface.hh"
#endif
#ifndef included_sidl_ClassInfo_hh
#include "sidl_ClassInfo.hh"
#endif
#ifndef included_sort_Comparator_hh
#include "sort_Comparator.hh"
#endif
#line 26 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
// DO-NOT-DELETE splicer.begin(sort.IntegerContainer._includes)
#include <sstream>
#include <iostream>
#include "synch_RegOut.hh"
// DO-NOT-DELETE splicer.end(sort.IntegerContainer._includes)
#line 32 "sort_IntegerContainer_Impl.cc"

// user defined constructor
void sort::IntegerContainer_impl::_ctor() {
#line 34 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._ctor)
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._ctor)
#line 39 "sort_IntegerContainer_Impl.cc"
}

// user defined destructor
void sort::IntegerContainer_impl::_dtor() {
#line 40 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._dtor)
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._dtor)
#line 47 "sort_IntegerContainer_Impl.cc"
}

// static class initializer
void sort::IntegerContainer_impl::_load() {
#line 46 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._load)
  // guaranteed to be called at most once before any other method in this class
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._load)
#line 56 "sort_IntegerContainer_Impl.cc"
}

// user defined static methods: (none)

// user defined non-static methods:
/**
 * This sets the container length and pseudo-randomly orders the
 * Integer elements contained.
 */
void
sort::IntegerContainer_impl::setLength_impl (
  /* in */int32_t len ) 
throw () 
{
#line 63 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.setLength)
  int32_t i, j;
  d_elements = ucxx::sidl::array<ucxx::sort::Integer>::create1d(len);
  for(i = 0; i < len; ++i){
    ucxx::sort::Integer intObj = ucxx::sort::Integer::_create();
    intObj.setValue(i);
    d_elements.set(i, intObj);
  }
  for(i = len - 1; i > 0; --i) {
    j = random() % (i + 1);
    if (j != i) {
      swap(i, j);
    }
  }
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.setLength)
#line 87 "sort_IntegerContainer_Impl.cc"
}

/**
 * Return the number of elements in the container.
 */
int32_t
sort::IntegerContainer_impl::getLength_impl () 
throw () 

{
#line 88 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.getLength)
  return 1 + d_elements.upper(0) - d_elements.lower(0);
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.getLength)
#line 102 "sort_IntegerContainer_Impl.cc"
}

/**
 * Return -1 if element i is less than element j, 0 if element i
 * is equal to element j, or otherwise 1.
 */
int32_t
sort::IntegerContainer_impl::compare_impl (
  /* in */int32_t i,
  /* in */int32_t j,
  /* in */::ucxx::sort::Comparator comp ) 
throw () 
{
#line 104 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.compare)
  ucxx::sidl::BaseInterface i1(d_elements.get(i));
  ucxx::sidl::BaseInterface i2(d_elements.get(j));
  return comp.compare(i1, i2);
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.compare)
#line 122 "sort_IntegerContainer_Impl.cc"
}

/**
 * Swap elements i and j.
 */
void
sort::IntegerContainer_impl::swap_impl (
  /* in */int32_t i,
  /* in */int32_t j ) 
throw () 
{
#line 120 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.swap)
  const int32_t len = getLength();
  if (i >= 0 && j >= 0 && i < len && j < len) {
    ucxx::sort::Integer 
      i1(d_elements.get(i)),
      i2(d_elements.get(j));
    d_elements.set(i, i2);
    d_elements.set(j, i1);
  }
  else {
    std::cerr << "sort::IntegerContainer::swap index out of bounds swap ("
	      << i << ", " << j << ") len (" << len << ")" << std::endl;
    ucxx::synch::RegOut::getInstance().forceFailure();
  }
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.swap)
#line 150 "sort_IntegerContainer_Impl.cc"
}

/**
 * Print elements s through e-1
 */
void
sort::IntegerContainer_impl::output_impl (
  /* in */int32_t s,
  /* in */int32_t e ) 
throw () 
{
#line 146 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.output)
  std::ostringstream buf;
  buf << "list";
  while (s < e) {
    buf << ' ' << d_elements.get(s++).getValue();
  }
  ucxx::synch::RegOut::getInstance().writeComment(buf.str());
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.output)
#line 171 "sort_IntegerContainer_Impl.cc"
}


#line 157 "../../../../babel/regression/sort/libUCxx/sort_IntegerContainer_Impl.cc"
// DO-NOT-DELETE splicer.begin(sort.IntegerContainer._misc)
// Put miscellaneous code here
// DO-NOT-DELETE splicer.end(sort.IntegerContainer._misc)
#line 179 "sort_IntegerContainer_Impl.cc"