Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

qarm/qarmtrandefinition.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 MyARM GbR, Germany
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or 
00006  * without modification, are permitted provided that the 
00007  * following conditions are met:
00008  * 1. Redistributions of source code must retain the above
00009  *    copyright notice, this list of conditions and the
00010  *    following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above
00012  *    copyright notice, this list of conditions and the
00013  *    following disclaimer in the documentation and/or other
00014  *    materials provided with the distribution.
00015  * 3. All advertising materials mentioning features or use of
00016  *    this software must display the following acknowledgement:
00017  *        This product includes software developed by
00018  *        MyARM GbR and its contributors.
00019  * 4. Neither the name of MyARM GbR nor the names of its
00020  *    contributors may be used to endorse or promote products
00021  *    derived from this software without specific prior written
00022  *    permission.
00023  * 
00024  * THIS SOFTWARE IS PROVIDED BY MYARM GBR. AND CONTRIBUTORS 
00025  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
00026  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00027  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00028  * SHALL MYARM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00029  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00032  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00033  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00035  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00036  * OF SUCH DAMAGE.
00037  */
00038 
00039 
00045 #include <QArmTranDefinition>
00046 #include <QArmAppDefinition>
00047 #include <QArmMetricList>
00048 
00049 #include "myarmsdk.h"
00050 #include "myarmsdk_dynload.h"
00051 
00052 /*---------------------------------------------------------------------------*/
00053 
00054 QArmTranDefinition::QArmTranDefinition(const QString              & _tranname,
00055                                        const QArmAppDefinition    * _app,
00056                                        const QArmIdentityPropList * _identity_props,
00057                                        const QArmContextNameList  * _context_names,
00058                                        const QArmMetricList       * _metric_bindings)
00059   : QArmDefinition(_tranname) {
00060 
00061   // Properties and/or metric bindings valid and available
00062   bool identity = (_identity_props != 0) && (_identity_props->count() > 0);
00063   bool context  = (_context_names != 0) && (_context_names->count() > 0);
00064   bool metrics  = (_metric_bindings != 0) && (_metric_bindings->count() > 0);
00065   int num_sb = 0;
00066 
00067   armsdk_buffer4_t sdk_buf4;
00068   armsdk_subbuffer_metric_bindings_t sdk_sb_metric_bindings;
00069   armsdk_subbuffer_tran_identity_t sdk_sb_tran_identity;
00070 
00071   // Identity and context properties are handled with the same subbuffer.
00072   if(identity || context) {
00073     // Initialize identity properties subbuffer.
00074     armsdk_tran_identity_initialize(&sdk_sb_tran_identity);
00075 
00076     // Add the subbuffer to the buffer4 structure. It registers the pointer
00077     // to the identity subbuffer. The content is filled in later.
00078     num_sb = addSubbuffer(num_sb, sdk_buf4, ARM_SDKSB(sdk_sb_tran_identity));
00079   }
00080 
00081   // Transaction identity properties are filled first.
00082   // Only use properties in case they are provided.
00083   if(identity) {
00084     // Iterate through the identity props and fill our array with values.
00085     QArmIdentityPropListIterator it( *_identity_props );
00086     int i = 0;
00087     while(it.hasNext()) {
00088       it.next();
00089       // Fill in identity property names and values.
00090       armsdk_tran_identity_set(&sdk_sb_tran_identity, 
00091                                i,
00092                                it.key().toAscii().constData(),
00093                                it.value()->toAscii().constData());
00094       i++;
00095     } //end for
00096   }
00097 
00098   // Transaction context names have to be handled similar.
00099   if(context) {
00100     // Context property names (no values).
00101     QArmContextNameListIterator it(*_context_names);
00102     int j = 0;
00103     while(it.hasNext()) {
00104       armsdk_tran_identity_context_name_set(&sdk_sb_tran_identity,
00105                                             j,
00106                                             it.next().toAscii().constData());
00107       j++;
00108     }
00109   }
00110 
00111   // Check for metric bindings.
00112   if(metrics) {
00113     // Initialize metric bindings subbuffer.
00114     armsdk_metric_binding_initialize(&sdk_sb_metric_bindings);
00115 
00116     // Traverse the list of metrics and fill the array.
00117     QArmMetricListIterator it(*_metric_bindings);
00118     int j = 0;
00119     while(it.hasNext()) {
00120       armsdk_metric_binding_set(&sdk_sb_metric_bindings,
00121                                 j,
00122                                 it.next()->getMetricId());
00123       j++;
00124     }
00125     num_sb = addSubbuffer(num_sb, sdk_buf4, ARM_SDKSB(sdk_sb_metric_bindings));
00126   }
00127   
00128   // Here we register:
00129   // - The transaction identity properties defined here.
00130   // - The transaction context property names that will be filled with
00131   //   content during start.
00132   // - The metric "bindings" that will be filled with content during start.
00133   arm_register_transaction(_app->getId(),/* in */
00134                            m_name.toAscii().constData(),/* transaction name*/
00135                            ARM_ID_NONE, 
00136                            ARM_FLAG_NONE,
00137                            (num_sb > 0) ? &sdk_buf4.header : ARM_BUF4_NONE,
00138                            &m_id);/* out */
00139 }
00140 
00141 /*---------------------------------------------------------------------------*/
00142 
00143 QArmTranDefinition::~QArmTranDefinition() {
00144 }
00145 

Generated on Thu Dec 15 19:14:20 2005 for QArm API by  doxygen 1.4.2