Browse Source

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 years ago
parent
commit
182de1201d
3 changed files with 101 additions and 15 deletions
  1. 8
    2
      SNF4CGP/Command.hpp
  2. 69
    13
      SNF4CGP/JobPool.cpp
  3. 24
    0
      SNF4CGP/JobPool.hpp

+ 8
- 2
SNF4CGP/Command.hpp View File

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

+ 69
- 13
SNF4CGP/JobPool.cpp View File

#include "Command.hpp" #include "Command.hpp"
#include "ScannerPool.hpp" #include "ScannerPool.hpp"
#include "../SNFMulti/SNFMulti.hpp"
#include "../CodeDweller/threading.hpp" #include "../CodeDweller/threading.hpp"
#include "../CodeDweller/faults.hpp" #include "../CodeDweller/faults.hpp"
using namespace std; using namespace std;
//// Tuning Constants //////////////////////////////////////////////////////////
const int ReadBufferSize = snf_ScanHorizon;
const int StringReserveSize = 2048;
//// Job /////////////////////////////////////////////////////////////////////// //// 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() { void Job::doWakeUp() {
} }
void Job::doFILE() { void Job::doFILE() {
} }
void Job::readTopOfMessage(ifstream& Reader) {
}
void Job::doRead() { void Job::doRead() {
} }
void Job::doDelete() { 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. Job::Job(ScannerPool& S, OutputProcessor& O) : // Construct with important links.
Scanners(S), Scanners(S),
Output(O), 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. 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. void Job::setCommand(Command& C) { // Assign a command for this job.
CurrentCommand = C;
} }
void Job::doIt() { // Get the job done. 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. string& Job::Responses() { // Read the job's report.
}
void Job::clear() { // Cleanup for the next command.
return OutputBuffer;
} }
//// JobPool /////////////////////////////////////////////////////////////////// //// JobPool ///////////////////////////////////////////////////////////////////

+ 24
- 0
SNF4CGP/JobPool.hpp View File

OutputProcessor& Output; OutputProcessor& Output;
Command CurrentCommand; // Has a current comand. Command CurrentCommand; // Has a current comand.
string OutputBuffer; // Preserves an output buffer. 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. vector<unsigned char> ReadBuffer; // Preserves a file read buffer.
unsigned int ReadLength; // How much data in the 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. //// These methods embody how we get jobs done.
void doWakeUp(); void doWakeUp();

Loading…
Cancel
Save