~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to examples/APG/Containers/Array.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Array.cpp,v 1.3 2004/01/05 22:57:06 shuston Exp
2
 
 
3
 
#include "ace/OS_Memory.h"
4
 
#include "ace/Log_Msg.h"
5
 
// Listing 1 code/ch05
6
 
#include "ace/Containers.h"
7
 
#include "DataElement.h"
8
 
 
9
 
int ACE_TMAIN (int, ACE_TCHAR *[])
10
 
{
11
 
  ACE_Array<DataElement*> arr (10);
12
 
  DataElement *elem = 0;
13
 
  // Allocate and insert elements.
14
 
  for (int i = 0; i < 10; i++)
15
 
    {
16
 
      ACE_NEW_RETURN (elem, DataElement (i), -1);
17
 
      arr[i] = elem;
18
 
    }
19
 
 
20
 
  // Checked access.
21
 
  ACE_ASSERT (arr.set (elem, 11) == -1);
22
 
  ACE_ASSERT (arr.get (elem, 11) == -1);
23
 
 
24
 
  // Make a copy and compare to the original.
25
 
  ACE_Array<DataElement*> copy = arr;
26
 
  ACE_ASSERT (copy == arr);
27
 
 
28
 
  ACE_Array<DataElement*>::ITERATOR iter (arr);
29
 
  while (!iter.done ())
30
 
    {
31
 
      DataElement** data;
32
 
      iter.next (data);
33
 
      ACE_DEBUG ((LM_DEBUG,
34
 
                  ACE_TEXT ("%d\n"), (*data)->getData ()));
35
 
      delete (*data);
36
 
      iter.advance ();
37
 
    }
38
 
  return 0;
39
 
}
40
 
// Listing 1
41
 
 
42
 
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
43
 
template class ACE_Array <DataElement*>;
44
 
template class ACE_Array_Base<DataElement*>;
45
 
template class ACE_Array_Iterator<DataElement*>;
46
 
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
47
 
#pragma instantiate ACE_Array <DataElement*>
48
 
#pragma instantiate ACE_Array_Base<DataElement*>
49
 
#pragma instantiate ACE_Array_Iterator<DataElement*>
50
 
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION*/