(file) Return to ExamplesClient.dxx CVS log (file) (dir) Up to [Pegasus] / pegasus / doc / DevManual

 1 karl  1.1 @name Client Examples
 2           /*
 3 karl  1.2 
 4 karl  1.1 */
 5           
 6           /** @name Client Coding Examples
 7           
 8           
 9           <B>Example 1</B>
10           
11           Declaration of a Class and the addition of qualifiers, properties,
12           and methods to that class.
13           Finally, the code converts the class defined to XML with print,
14           outputs it, restores it to a new class and compares the results.
15           
16           This example is one of the tests defined for Pegasus in the
17           /commmon/tests directory
18           
19           <PRE><CODE>
20           Example of Class Declaration
21           
22           #include <Pegasus/ClassDecl.h>
23           #include <Pegasus/Name.h>
24           
25 karl  1.1 using namespace Pegasus;
26           
27           void test01()
28           {
29               ClassDecl class1("MyClass", "YourClass");
30           
31               class1
32           	.addQualifier(Qualifier("association", true))
33           	.addQualifier(Qualifier("q1", Uint32(55)))
34           	.addQualifier(Qualifier("q2", "Hello"))
35           	.addProperty(Property("message", "Hello"))
36           	.addProperty(Property("count", Uint32(77)))
37           	.addProperty(
38           	    Property("ref1", Reference("MyClass.key1=\"fred\""), "MyClass"))
39           	.addMethod(Method("isActive", Type::BOOLEAN)
40           	    .addParameter(Parameter("hostname", Type::STRING))
41           	    .addParameter(Parameter("port", Type::UINT32)));
42           
43               // class1.print();
44           
45               OutBuffer out;
46 karl  1.1     out << class1;
47           
48               InBuffer in(out.getData());
49               ClassDecl tmp;
50               in >> tmp;
51           
52               assert(class1.identical(tmp));
53           }
54           
55           int main()
56           {
57               try
58               {
59           	test01();
60               }
61               catch (Exception& e)
62               {
63           	cout << "Exception: " << e.getMessage() << endl;
64               }
65           
66               cout << "+++++ passed all tests" << endl;
67 karl  1.1 
68               return 0;
69           }
70           
71           </CODE/>
72           </PRE>
73           */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2