transport: pass correct channel
[abstract.git] / report / aaTranscript.cpp
blobede5f6c46531826b9b6f9377da8ff3d9d91acae1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2007,2008 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "xpcom-config.h"
24 #include "nsCOMPtr.h"
25 #include "nsComponentManagerUtils.h"
26 #include "nsIArray.h"
27 #include "nsArrayUtils.h"
28 #include "nsStringAPI.h"
30 /* Unfrozen API */
32 /* Project includes */
33 #include "nsStringUtils.h"
34 #include "aaIFlow.h"
35 #include "aaIBalance.h"
36 #include "aaITransaction.h"
38 #include "aaTranscript.h"
40 aaTranscript::aaTranscript(aaITranscriptParam *aParam)
41 :mTotalDebits(0.0), mTotalCredits(0.0), mTotalDebitsValue(0.0),
42 mTotalCreditsValue(0.0), mTotalDebitsDiff(0.0), mTotalCreditsDiff(0.0)
44 mStatus = init(aParam);
47 nsresult
48 aaTranscript::init(aaITranscriptParam *aParam)
50 NS_ENSURE_ARG_POINTER(aParam);
51 nsresult rv;
53 rv = aParam->GetFlow(getter_AddRefs(mFlow));
54 NS_ENSURE_TRUE(mFlow, NS_ERROR_INVALID_ARG);
56 rv = aParam->GetStart(&mStart);
57 NS_ENSURE_SUCCESS(rv, rv);
59 rv = aParam->GetEnd(&mEnd);
60 NS_ENSURE_SUCCESS(rv, rv);
62 return NS_OK;
65 NS_IMPL_ISUPPORTS2(aaTranscript,
66 nsIArray,
67 aaITranscript)
69 /* nsIArray */
70 NS_IMETHODIMP
71 aaTranscript::GetLength(PRUint32 *aLength)
73 NS_ENSURE_ARG_POINTER(aLength);
74 *aLength = mList.Count();
75 return NS_OK;
78 NS_IMETHODIMP
79 aaTranscript::QueryElementAt(PRUint32 index, const nsIID & uuid, void * *result)
81 NS_ENSURE_ARG_POINTER(result);
82 NS_ENSURE_TRUE(index < (PRUint32) mList.Count(), NS_ERROR_INVALID_ARG);
83 return mList[index]->QueryInterface(uuid, result);
86 NS_IMETHODIMP
87 aaTranscript::IndexOf(PRUint32 startIndex, nsISupports *element, PRUint32 *_retval)
89 return NS_ERROR_NOT_IMPLEMENTED;
92 NS_IMETHODIMP
93 aaTranscript::Enumerate(nsISimpleEnumerator **_retval)
95 return NS_ERROR_NOT_IMPLEMENTED;
99 /* aaITranscript */
100 NS_IMETHODIMP
101 aaTranscript::GetFlow(aaIFlow * *aFlow)
103 NS_ENSURE_ARG_POINTER(aFlow);
104 NS_IF_ADDREF(*aFlow = mFlow);
105 return NS_OK;
108 NS_IMETHODIMP
109 aaTranscript::GetOpening(aaIBalance * *aOpen)
111 NS_ENSURE_ARG_POINTER(aOpen);
112 NS_IF_ADDREF(*aOpen = mOpen);
113 return NS_OK;
116 NS_IMETHODIMP
117 aaTranscript::GetClosing(aaIBalance * *aClose)
119 NS_ENSURE_ARG_POINTER(aClose);
120 NS_IF_ADDREF(*aClose = mClose);
121 return NS_OK;
124 NS_IMETHODIMP
125 aaTranscript::GetTotalDebits(double *aTotalDebits)
127 NS_ENSURE_ARG_POINTER(aTotalDebits);
129 *aTotalDebits = mTotalDebits;
130 return NS_OK;
133 NS_IMETHODIMP
134 aaTranscript::GetTotalCredits(double *aTotalCredits)
136 NS_ENSURE_ARG_POINTER(aTotalCredits);
138 *aTotalCredits = mTotalCredits;
139 return NS_OK;
142 NS_IMETHODIMP
143 aaTranscript::GetTotalDebitsValue(double *aTotalDebitsValue)
145 NS_ENSURE_ARG_POINTER(aTotalDebitsValue);
147 *aTotalDebitsValue = mTotalDebitsValue;
148 return NS_OK;
151 NS_IMETHODIMP
152 aaTranscript::GetTotalCreditsValue(double *aTotalCreditsValue)
154 NS_ENSURE_ARG_POINTER(aTotalCreditsValue);
156 *aTotalCreditsValue = mTotalCreditsValue;
157 return NS_OK;
160 NS_IMETHODIMP
161 aaTranscript::GetTotalDebitsDiff(double *aTotalDebitsDiff)
163 NS_ENSURE_ARG_POINTER(aTotalDebitsDiff);
165 *aTotalDebitsDiff = mTotalDebitsDiff;
166 return NS_OK;
169 NS_IMETHODIMP
170 aaTranscript::GetTotalCreditsDiff(double *aTotalCreditsDiff)
172 NS_ENSURE_ARG_POINTER(aTotalCreditsDiff);
174 *aTotalCreditsDiff = mTotalCreditsDiff;
175 return NS_OK;