aboutsummaryrefslogtreecommitdiff
path: root/examples/cxx/hybrid/streaming/object-pimpl.cxx
blob: 3f45c79d344e2ef9595226c19cb3719b9aae1928 (plain)
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
// file      : examples/cxx/hybrid/streaming/object-pimpl.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : not copyrighted - public domain

#include <iostream>

// Include position-pimpl.hxx (which includes object-pimpl.hxx)
// instead of object-pimpl.hxx.
//
#include "position-pimpl.hxx"

using namespace std;

void object_pimpl::
pre ()
{
  // Initialize the variables.
  //
  count_ = 0;
  avg_lat_ = 0.0;
  avg_lon_ = 0.0;
}

void object_pimpl::
id (unsigned int id)
{
  id_ = id;
}

void object_pimpl::
position (const ::position& p)
{
  count_++;
  avg_lat_ += p.lat ();
  avg_lon_ += p.lon ();
}

object* object_pimpl::
post_object ()
{
  avg_lat_ /= count_;
  avg_lon_ /= count_;

  cerr << "object " << id_ << ": " << avg_lat_ << " " << avg_lon_ << endl;

  return 0; // We don't construct the object so return NULL.
}