/[resiprocate]/main/resip/stack/test/testId.cxx
ViewVC logotype

Contents of /main/resip/stack/test/testId.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5948 - (show annotations) (download)
Fri Feb 17 15:30:16 2006 UTC (13 years, 8 months ago) by dworley
File MIME type: text/plain
File size: 4035 byte(s)
Setting more svn: properties, and adding EOLs to the ends of files
that need it.

1 #include <iostream>
2
3 #include "rutil/Id.hxx"
4
5 //class A;
6
7 //template class resip::Id<A>;
8
9 //resip::Id<A>::value_type resip::Id<A>::theGenerator = 0;
10 //resip::Id<A>::map_type resip::Id<A>::theIdMap;
11
12 using namespace std;
13
14 class A;
15 template class resip::Id<A>;
16
17 class A
18 {
19 public:
20 typedef resip::Id<A> Id;
21
22 //friend ostream& operator<<(ostream& , const A&);
23
24 A();
25 virtual ~A();
26 const A::Id& getId() const;
27 int callme() { return mynumber; }
28 private:
29 static int generator;
30 int mynumber;
31 A::Id mId;
32
33 };
34
35 int A::generator = 100;
36 #if 0
37 ostream& operator << (ostream& os, const A& a)
38 {
39 os << "A(mynumber=" << a.mynumber << " id=" << a.mId.value() << ')' <<endl;
40 return os;
41 }
42 #endif
43
44 A::A() : mynumber(++generator) {};
45
46 A::~A(){};
47
48 const A::Id&
49 A::getId() const { return mId; }
50
51
52 int
53 main(int, char*[])
54 {
55 A arr[4];
56
57 for(unsigned int i = 0 ; i < sizeof(arr)/sizeof(*arr); i++)
58 {
59 cout << "arr["<<i<<"].getId().value() == " << arr[i].getId().value()
60 << endl
61 << " and access example: "
62 << " arr["<<i<<"].getId()->callme() == "
63 << arr[i].getId()->callme()
64 << endl;
65 }
66
67
68 A* na = new A;
69
70 A::Id aid( na->getId());
71
72 cout << "na==" << (void*)na << endl;
73 cout << "na->callme(): " << na->callme() << endl;
74 if (aid.valid())
75 {
76 cout << "aid is valid" << endl;
77 cout << "aid->callme() " << aid->callme() << endl;
78 cout << "deleting na" << endl;
79 }
80 delete na;
81 cout << "aid.valid() == " << aid.valid() << endl;
82
83 return 0;
84 }
85
86 /* ====================================================================
87 * The Vovida Software License, Version 1.0
88 *
89 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved.
90 *
91 * Redistribution and use in source and binary forms, with or without
92 * modification, are permitted provided that the following conditions
93 * are met:
94 *
95 * 1. Redistributions of source code must retain the above copyright
96 * notice, this list of conditions and the following disclaimer.
97 *
98 * 2. Redistributions in binary form must reproduce the above copyright
99 * notice, this list of conditions and the following disclaimer in
100 * the documentation and/or other materials provided with the
101 * distribution.
102 *
103 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
104 * and "Vovida Open Communication Application Library (VOCAL)" must
105 * not be used to endorse or promote products derived from this
106 * software without prior written permission. For written
107 * permission, please contact vocal@vovida.org.
108 *
109 * 4. Products derived from this software may not be called "VOCAL", nor
110 * may "VOCAL" appear in their name, without prior written
111 * permission of Vovida Networks, Inc.
112 *
113 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
114 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
115 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
116 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
117 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
118 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
119 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
120 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
121 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
122 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
124 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
125 * DAMAGE.
126 *
127 * ====================================================================
128 *
129 * This software consists of voluntary contributions made by Vovida
130 * Networks, Inc. and many individuals on behalf of Vovida Networks,
131 * Inc. For more information on Vovida Networks, Inc., please see
132 * <http://www.vovida.org/>.
133 *
134 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27