Преглед изворни кода

Added utility method skeleton to Job class.

Built a bit more of Job class guts.


git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@21 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfc
master
madscientist пре 15 година
родитељ
комит
182de1201d
3 измењених фајлова са 101 додато и 15 уклоњено
  1. 8
    2
      SNF4CGP/Command.hpp
  2. 69
    13
      SNF4CGP/JobPool.cpp
  3. 24
    0
      SNF4CGP/JobPool.hpp

+ 8
- 2
SNF4CGP/Command.hpp Прегледај датотеку

@@ -26,13 +26,13 @@ class Command {
CommandType Type; // Commands have a type.
string Data; // Other command data goes here.
Command::Command() : // Ordinary constructor.
Command() : // Ordinary constructor.
Number(0),
Type(UNKNOWN),
Data("") {
}
Command::Command(const Command& R) : // Copy constructor.
Command(const Command& R) : // Copy constructor.
Number(R.Number),
Type(R.Type) {
Data = R.Data;
@@ -44,6 +44,12 @@ class Command {
Data = R.Data;
return (*this);
}
void clear() { // Clear the command as if new.
Type = UNKNOWN;
Number = 0;
Data.clear();
}
};
#endif

+ 69
- 13
SNF4CGP/JobPool.cpp Прегледај датотеку

@@ -6,6 +6,8 @@
#include "Command.hpp"
#include "ScannerPool.hpp"
#include "../SNFMulti/SNFMulti.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/faults.hpp"
@@ -14,8 +16,43 @@
using namespace std;
//// Tuning Constants //////////////////////////////////////////////////////////
const int ReadBufferSize = snf_ScanHorizon;
const int StringReserveSize = 2048;
//// Job ///////////////////////////////////////////////////////////////////////
void Job::emitCommentPrefix() {
}
void Job::emitComment(string Comment) {
}
void Job::emitResponsePrevix() {
}
void Job::emitOK() {
}
void Job::emitINTF() {
}
void Job::emitFAIL() {
}
void Job::emitADDHEADER(string Headers) {
}
void Job::emitERROR() {
}
void Job::emitDISCARD() {
}
void job::finalize() {
}
void Job::doWakeUp() {
}
@@ -28,6 +65,9 @@ void Job::doFAIL() {
void Job::doFILE() {
}
void Job::readTopOfMessage(ifstream& Reader) {
}
void Job::doRead() {
}
@@ -49,37 +89,53 @@ void Job::doReject() {
void Job::doDelete() {
}
void Job::doHold() {
void Job::moveMessageToHoldPath(ifstream& Reader) {
}
/*
ScannerPool& Scanners; // Knows where to get scanners.
OutputProcessor& Output;
Command CurrentCommand; // Has a current comand.
string OutputBuffer; // Preserves an output buffer.
vector<unsigned char> ReadBuffer; // Preserves a file read buffer.
unsigned int ReadLength; // How much data in the buffer.
*/
void Job::doHold() {
}
Job::Job(ScannerPool& S, OutputProcessor& O) : // Construct with important links.
Scanners(S),
Output(O),
ReadLength(0) {
ScanResultCode(0),
ReadLength(0) { // Minimize heap thrashing.
OutputBuffer.reserve(StringReserveSize);
HeadersToInject.researve(StringReserveSize);
ReadBuffer.reserve(ReadBufferSize);
}
Job::~Job() { // Cleanup when destructing.
try { clear(); }
catch(...) {}
}
void Job::clear() { // Cleanup for the next command.
CurrentCommand.clear();
ScanResultCode = 0;
OutputBuffer.clear();
HeadersToInject.clear();
MessageMoveFilePath.clear();
ReadBuffer.clear();
ReadLength = 0;
}
void Job::setCommand(Command& C) { // Assign a command for this job.
CurrentCommand = C;
}
void Job::doIt() { // Get the job done.
switch(CurrentCommand.Type) {
case Command::WAKE: { doWakeUp(); break; }
case Command::INTF: { doINTF(); break; }
case Command::FILE: { doFILE(); break; }
default: { doFAIL(); break; }
}
finalize();
}
string& Job::Responses() { // Read the job's report.
}
void Job::clear() { // Cleanup for the next command.
return OutputBuffer;
}
//// JobPool ///////////////////////////////////////////////////////////////////

+ 24
- 0
SNF4CGP/JobPool.hpp Прегледај датотеку

@@ -41,9 +41,33 @@ class Job {
OutputProcessor& Output;
Command CurrentCommand; // Has a current comand.
string OutputBuffer; // Preserves an output buffer.
//// SNF Scan and move data and tools
int ScanResultCode;
string HeadersToInject;
string MessageMoveFilePath;
vector<unsigned char> ReadBuffer; // Preserves a file read buffer.
unsigned int ReadLength; // How much data in the buffer.
void readTopOfMessage(ifstream& Reader);
void moveMessageToHoldPath(ifstream& Reader);
//// Utility methods
void emitCommentPrefix();
void emitComment(string Comment);
void emitResponsePrevix();
void emitOK();
void emitINTF();
void emitFAIL();
void emitADDHEADER(string Headers);
void emitERROR();
void emitDISCARD();
void finalize();
//// These methods embody how we get jobs done.
void doWakeUp();

Loading…
Откажи
Сачувај