您的位置:首页 > 其它

图书馆信息管理系统文档

2016-12-29 08:57 232 查看

一. 概述

1.目录结构



文件说明

1. Data_Structure.h

定义了依赖的数据结构

2. CBook.h

定义”Book”类

3. CData_Processor.h

定义”Data_Processor”类,用于处理数据结构

4. CLibrary.h

定义“Library”类,用于处理对”Book”的相关操作

5.CSearch_Book.h

定义查找类,以要求的方式对书籍进行查找

6. CSort.h

定义排序类,以各种方式对书籍进行排序

7. CInitializer.h

定义”初始化”类,负责处理将硬盘中的文件读入内存中的操作

8. CLogFile.h

定义”日志文件”类,负责软件运行过程中事件 的记录

9. CLogIn_Out.h

负责普通用户及管理员登入登出操作

10. Comp_Functions.h

自定义比较函数,作为仿函数传递给std::sort

11. Finder_Structures.h

自定义结构,作为仿函数传递给std::find_if

12. CPassword.h

负责处理用户输入密码时以”*”代替的需求

13. Time_struct.h

负责获取系统时间

以上文件,其同名cpp文件均为其具体实现

2. 依赖的数据结构

(1)一些宏定义

这里写代码片//Some macro defination
#define Book_ID int //ID of a book(图书编号)
#define Book_Title string //Title of a book(标题)
#define Auth_Name string //Author's name(作者)
#define Classify_ID string //(分类号)
#define Pub_Dep string //Publish department (出版社)
#define Pub_Tim string //The publishing time of a book(出版日期)
#define Auth_Pub string //A publish department ,which publish one author's book(出版了某作者全部书的出版社)
#define Pub_Auth string //All author belongs to the publish department(某社所有签约作者)
#define Book_Price float //(价格)
#define Auth_Comm_Add string //Add is the method you can connect with the author(作者联系方式)
#define Pub_Comm_Add string //the method you can connect with the publish department
#define Sear_Freq int //the search frequency of a book
#define Surplus int//the residue of a book
#define Status bool//The status of a book
#define Bor_Tim int//The longest time of a book can be borrowed


程序中,一本书的相关信息以一个结构体的形式进行存储,结构体定义如下:

//Defination of Book
struct SBook{
SBook(){}
SBook(
Surplus sur,
Sear_Freq freq,
Book_ID bid,
Book_Title tit,
Auth_Name name,
Classify_ID cid,
Pub_Dep pub,
Book_Price price,
Pub_Tim time,
Bor_Tim btime=0,
Status state=false,
SBook * pt = nullptr
) :B_surplus(sur), S_Freq(freq), B_Id(bid), B_Tit(tit), A_Name(name), C_Id(cid), P_Dep(pub), B_Pri(price), P_Tim(time), isBorrow(state), b_Time(btime),pNext_Book(pt){}

bool operator <(const SBook & book){ return B_surplus < book.B_surplus; }

Surplus B_surplus;//剩余量
Sear_Freq S_Freq; //(查找频率)
Book_ID B_Id; //(书目编号)
Book_Title B_Tit; //(书名)
Auth_Name A_Name; //(作者名)
Classify_ID C_Id; //(分类号)
Pub_Dep P_Dep; //(出版社名)
Book_Price B_Pri; //(价格)
Pub_Tim P_Tim;//(出版日期)
Status isBorrow;//(是否被借阅)
Bor_Tim b_Time;//最长借阅时间
list<SBook> book_Ls;//构造Classify_Tree
};


其中包含一些书籍所必须包含的属性,如”标题”,”作者”等,还包含一个构造函数,用于对新声明的书进行初始化,以及一个重载后的”<”,用于比较两个”Book”结构的关系。

除了”Book”结构之外,还有”Author”结构,”SPublish_Dep”结构,分别用来定义”作者”和”出版社”类型。

此外,本文件中还定义了程序中最重要的一个数据结构,即Classify_Tree,下文将着重说明

Classify_Tree

所谓“Classify_Tree”,是一个含有四条链表头结点的向量,因其结构类似一棵树,且起到的是分类的作用,故称其为”Classify_Tree”,即”分类树”。在本程序中的作用在于,提升查找效率。



如图所示,如果遇到某两本书具有相同的标题,但其作者名,出版社,或其他属性不同时(这是图书馆中非常常见的情况),通过调用在Data_Processor类中定义的一个接口,即可将其按如图所示的方法加入分类树。

如果没有这棵分类树,而将所有书全部储存在一个链表之中,那么在以”标题”来进行查找时,就需要遍历整个链表才能保证将所有具有同一标题的书全部找到,如果这本书只有一本且处于靠近头结点的位置,那么所有后续的遍历都是在浪费时间。藏书量较小时可能无法体现出来,但藏书量巨大以及查找操作需要频繁进行时,其时间上的巨大差距将明显地显现出来。

此外,本程序对于查找函数还做了其他方面的优化,在CSearch_Book.h头文件中,加入了一个vector cache,对高频查找书籍进行了缓存,在每次查找过程中,先对缓存中的书籍进行遍历,如果存在则直接返回;不存在,则进入分类树进行查找。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: