RecordProcess.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. // RecordProcess.cpp: implementation of the RecordProcess class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "RecordProcess.h"
  6. //////////////////////////////////////////////////////////////////////
  7. // Construction/Destruction
  8. //////////////////////////////////////////////////////////////////////
  9. RecordProcess::RecordProcess()
  10. {
  11. }
  12. RecordProcess::~RecordProcess()
  13. {
  14. }
  15. void RecordProcess::AddProcessFunction(ItermProcess * Function)
  16. {
  17. if(FindFunction(Function->GetType()) == m_FunctionSet.end())
  18. {
  19. m_FunctionSet.push_back(Function);
  20. }
  21. }
  22. ItermProcessSet::iterator RecordProcess::FindFunction(const string &Type)
  23. {
  24. ItermProcessSet::iterator Pointer;
  25. /* for(Pointer = m_FunctionSet.begin();Pointer!=m_FunctionSet.end();Pointer++)
  26. {
  27. if((* Pointer)->GetType() == Type)
  28. {
  29. return Pointer;
  30. }
  31. }
  32. */
  33.     Pointer = find_if(m_FunctionSet.begin(),m_FunctionSet.end(),ItermProcessTypeCheck(Type));
  34. return Pointer;
  35.     
  36. }
  37. void RecordProcess::RemoveProcess(const string &Type)
  38. {
  39. ItermProcessSet::iterator Position = FindFunction(Type);
  40. if(Position != m_FunctionSet.end())
  41. {
  42. m_FunctionSet.erase(Position);
  43. }
  44. }
  45. void RecordProcess::Reset()
  46. {
  47. ItermProcessSet::iterator Pointer;
  48. for(Pointer = m_FunctionSet.begin();Pointer!=m_FunctionSet.end();Pointer++)
  49. {
  50. (*Pointer)->Reset();
  51. }
  52. }
  53. void RecordProcess::AnalyseRecordStream(istream &RecordStream)
  54. {
  55. while(!RecordStream.eof())
  56. {
  57. AnalyseARecord(RecordStream);
  58. }
  59.     
  60. }
  61. void RecordProcess::AnalyseARecord(istream &RecordStream)
  62. {
  63. string Title;
  64. GetALineFromStream(Title,RecordStream);
  65. ItermProcessSet::iterator Pointer;
  66. for(Pointer = m_FunctionSet.begin();Pointer!=m_FunctionSet.end();Pointer++)
  67. {
  68. if((* Pointer)->ProcessIterm(Title,RecordStream))
  69. {
  70. break;
  71. }
  72. }
  73. }