implement data hiding for account structures

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@674 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-03-20 05:20:58 +00:00
parent ae0ac46d64
commit e1cd45c458
10 changed files with 84 additions and 34 deletions

View File

@ -26,6 +26,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "Group.h"
#include "date.h"
#include "messages.h"

View File

@ -51,36 +51,6 @@ enum {
* the enumerated types above */
extern char *account_type_name[];
/** STRUCTS *********************************************************/
typedef struct _Account {
/* public data, describes account */
struct _account_group *parent; /* back-pointer to parent */
struct _account_group *children; /* pointer to sub-accounts */
int id; /* unique account id, internally assigned */
char flags;
short type;
char *accountName;
char *description;
char *notes;
/* protected data, cached parameters */
double balance;
double cleared_balance;
double reconciled_balance;
double running_balance;
double running_cleared_balance;
double running_reconciled_balance;
int numSplits; /* length of splits array below */
Split **splits; /* ptr to array of ptrs to splits */
/* the modified flag helps the gui keep track of
* changes to this account */
short changed;
} Account;
/** PROTOTYPES ******************************************************/
Account *xaccMallocAccount( void );
@ -137,8 +107,6 @@ void xaccConsolidateTransactions (Account *);
void xaccMoveFarEnd (Split *, Account *);
void xaccMoveFarEndByName (Split *, const char *);
Account * xaccSplitGetAccount (Split *);
/** GLOBALS *********************************************************/
extern int next_free_unique_account_id;

73
src/engine/AccountP.h Normal file
View File

@ -0,0 +1,73 @@
/*
* FILE:
* AccountP.h
*
* FUNCTION:
* This is the *private* header for the account structure.
* No one outside of the engine should ever include this file.
*
*/
/********************************************************************\
* Account.h -- the Account data structure *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998 Linas Vepstas *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* *
* Author: Rob Clark *
* Internet: rclark@cs.hmc.edu *
* Address: 609 8th Street *
* Huntington Beach, CA 92648-4632 *
\********************************************************************/
#ifndef __XACC_ACCOUNT_P_H__
#define __XACC_ACCOUNT_P_H__
#include "config.h"
#include "Transaction.h"
/** STRUCTS *********************************************************/
struct _account {
/* public data, describes account */
struct _account_group *parent; /* back-pointer to parent */
struct _account_group *children; /* pointer to sub-accounts */
int id; /* unique account id, internally assigned */
char flags;
short type;
char *accountName;
char *description;
char *notes;
/* protected data, cached parameters */
double balance;
double cleared_balance;
double reconciled_balance;
double running_balance;
double running_cleared_balance;
double running_reconciled_balance;
int numSplits; /* length of splits array below */
Split **splits; /* ptr to array of ptrs to splits */
/* the modified flag helps the gui keep track of
* changes to this account */
short changed;
};
#endif /* __XACC_ACCOUNT_P_H__ */

View File

@ -84,6 +84,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "FileIO.h"
#include "Group.h"
#include "messages.h"

View File

@ -26,6 +26,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "Group.h"
#include "TransactionP.h"
#include "util.h"

View File

@ -21,6 +21,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "Group.h"
#include "Transaction.h"
#include "util.h"

View File

@ -34,6 +34,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "Group.h"
#include "FileIO.h"
#include "TransactionP.h"

View File

@ -28,6 +28,7 @@
#include "config.h"
#include "Account.h"
#include "AccountP.h"
#include "date.h"
#include "Transaction.h"
#include "TransactionP.h"

View File

@ -48,6 +48,7 @@
* between "dining", "tips" and "taxes" categories.
*/
typedef struct _account Account;
typedef struct _split Split;
typedef struct _transaction Transaction;
@ -148,6 +149,8 @@ double xaccSplitGetAmount (Split * split);
double xaccSplitGetValue (Split * split);
double xaccSplitGetSharePrice (Split * split);
Account * xaccSplitGetAccount (Split *);
/********************************************************************\
* sorting comparison function
*

View File

@ -57,8 +57,8 @@
*/
struct _split {
struct _account *acc; /* back-pointer to debited/credited account */
struct _transaction *parent; /* parent of split */
Account *acc; /* back-pointer to debited/credited account */
Transaction *parent; /* parent of split */
char * memo;
char * action; /* Buy, Sell, Div, etc. */
char reconciled;