📄 depot_i.c
字号:
#include <fstream.h>//#include <iostream.h>/* #include <### PNS interface header file> */#include <PNS.h>#include "Depot_i.h"#include <FindPNS.h>const int NITEMTYPES=3;const char *depotdata_file = "depot.dat";const char *itemtypestext[NITEMTYPES] = {"FOOD","CLOTHES","OTHER"};Depot_i::Depot_i(PseudoNameService_ptr pns){ AStore::ItemInfo loaditem; loaditem.Item = new char[30]; loaditem.Name = new char[40]; char tempstring[30]; int i; ifstream is(depotdata_file); if (!is) { cerr << "Could not open depot data file" << depotdata_file << endl; return; } while (!is.eof()) { is >> loaditem.Item; is >> loaditem.Name; is >> loaditem.Quantity; is >> loaditem.Itemcost; // Read in the string containing the itemtype and convert it to an // enumerated value is >> tempstring; i=0; while (i < NITEMTYPES && strcmp(tempstring,itemtypestext[i]) != 0) i++; if (i < NITEMTYPES) { loaditem.Itemtype=AStore::ItemTypes(i); m_items.Insert(loaditem); } } // Register the object with the name service try { // cout<<" next is Binding name server"<<endl; pns->BindName("Depot", _this()); // cout << " Binding Depot is OK now! "<<endl; } catch(...) { cerr << "Trouble Binding Depot" << endl; }}void Depot_i::FindItemInfo (CORBA::Long StoreId, const char *Item,/* const POS::Barcode Item,*/ CORBA::Long Quantity, /* AStore::ItemInfo_out IInfo) */ AStore::ItemInfo*& IInfo){ IInfo = new AStore::ItemInfo; if (!m_items.Locate(Item,*IInfo)) { AStore::BarcodeNotFound *bcnf = new AStore::BarcodeNotFound; bcnf->item = Item; // Raise the exception here throw(*bcnf); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -