neic-glass3  1.4.6
Public Member Functions | Protected Member Functions | List of all members
glass3::fileInput Class Reference

glass fileInput class More...

#include <fileInput.h>

Inheritance diagram for glass3::fileInput:
Inheritance graph
Collaboration diagram for glass3::fileInput:
Collaboration graph

Public Member Functions

 fileInput ()
 fileInput constructor More...
 
 fileInput (const std::shared_ptr< const json::Object > &config)
 fileInput advanced constructor More...
 
 ~fileInput ()
 fileInput destructor More...
 
bool setup (std::shared_ptr< const json::Object > config) override
 fileInput configuration function More...
 
void clear () override
 output clear function More...
 
const std::string getInputDir ()
 Function to retrieve the name of the input directory. More...
 
void setInputDir (const std::string &dir)
 Function to set the name of the input directory. More...
 
const std::string getArchiveDir ()
 Function to retrieve the name of the archive directory. More...
 
void setArchiveDir (const std::string &dir)
 Function to set the name of the archive directory. More...
 
const std::string getFormat ()
 Function to retrieve the format type (extension) More...
 
void setFormat (const std::string &format)
 Function to set the format type (extension) More...
 
void setShutdownWhenNoData (bool shutdown)
 Function to set whether to shutdown when no data. More...
 
bool getShutdownWhenNoData ()
 Function to retrieve whether to shutdown when no data. More...
 
void setShutdownWait (int waitTime)
 Function to set the shutdown wait time. More...
 
int getShutdownWait ()
 Function to retrieve the shutdown wait time. More...
 
- Public Member Functions inherited from glass3::input::Input
 Input ()
 Input default constructor. More...
 
 Input (std::shared_ptr< const json::Object > config)
 Input advanced constructor. More...
 
 ~Input ()
 Input destructor. More...
 
std::shared_ptr< json::Object > getInputData () override
 Input data getting function. More...
 
int getInputDataCount () override
 Input data count function. More...
 
void setInputDataMaxSize (int size)
 Function to set the maximum queue size. More...
 
int getInputDataMaxSize ()
 Function to retrieve the maximum queue size. More...
 
- Public Member Functions inherited from glass3::util::ThreadBaseClass
 ThreadBaseClass ()
 ThreadBaseClass constructor. More...
 
 ThreadBaseClass (std::string threadName, int sleepTimeMS=100, int numThreads=1, int checkInterval=300)
 An advanced constructor that sets up the ThreadBaseClass with a provided thread name, sleep between work time duration, number of threads, and statsus check interval. More...
 
 ~ThreadBaseClass ()
 ThreadBaseClass destructor. More...
 
virtual bool start ()
 work thread start function More...
 
virtual bool stop ()
 work thread stop function More...
 
int getNumThreads ()
 Retrieves the number of work threads. More...
 
void setNumThreads (int numThreads)
 Sets the number of work threads. More...
 
void setThreadHealth (bool health=true)
 Function to set thread health. More...
 
virtual bool healthCheck ()
 work threads check function More...
 
void setSleepTime (int sleepTimeMS)
 Sets the time to sleep between work() calls. More...
 
int getSleepTime ()
 Retrieves the time to sleep between work() calls. More...
 
glass3::util::ThreadState getWorkThreadsState ()
 Function to get the work threads state. More...
 
void setHealthCheckInterval (int interval)
 Function to set work threads health check interval. More...
 
int getHealthCheckInterval ()
 Function to retrieve the work threads health check interval. More...
 
bool getTerminate ()
 Function to retrieve whether the thread should terminate. More...
 
const std::string & getThreadName ()
 Function to retrieve the name of the work threads. More...
 
std::time_t getAllLastHealthy (size_t *pThreadId)
 Function to retrieve the oldest time any of the work threads last updated their health status as healthy. More...
 
- Public Member Functions inherited from glass3::util::BaseClass
 BaseClass ()
 BaseClass constructor. More...
 
virtual ~BaseClass ()
 BaseClass destructor. More...
 
const std::shared_ptr< const json::Object > getConfig ()
 
bool getSetup ()
 Retrieves the class member boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
const std::string & getDefaultAgencyId ()
 Function to retrieve the name of the default agency id. More...
 
void setDefaultAgencyId (const std::string &id)
 Function to set the name of the default agency id. More...
 
const std::string & getDefaultAuthor ()
 Function to retrieve the name of the default author. More...
 
void setDefaultAuthor (const std::string &author)
 Function to set the name of the default author. More...
 

Protected Member Functions

std::string fetchRawData (std::string *pOutType) override
 get input data string and type More...
 
void cleanupFile (std::string filename, bool move, std::string destinationdir)
 cleanup file function More...
 
- Protected Member Functions inherited from glass3::input::Input
glass3::util::WorkState work () override
 Input work function. More...
 
virtual std::shared_ptr< json::Object > parse (std::string inputType, std::string inputMessage)
 parse line function More...
 
- Protected Member Functions inherited from glass3::util::ThreadBaseClass
void setWorkThreadsState (glass3::util::ThreadState state)
 Function to set threads state. More...
 
void workLoop ()
 ThreadBaseClass work loop function. More...
 
void setLastHealthy (std::time_t now)
 Function to set the last time the work thread was healthy. More...
 

Additional Inherited Members

- Protected Attributes inherited from glass3::util::ThreadBaseClass
std::vector< std::thread > m_WorkThreads
 the std::vector that contains the work std::thread objects More...
 
std::map< std::thread::id, std::atomic< int > > m_ThreadHealthMap
 A std::map containing the epoch times as std::atomic<double>> that each work thread was last marked as healthy, identified by the thread id. More...
 
- Protected Attributes inherited from glass3::util::BaseClass
std::shared_ptr< const json::Object > m_Config
 A shared pointer to the json::Object that holds the configuration. More...
 
std::atomic< bool > m_bIsSetup
 the boolean flag indicating whether the class has been setup, set to true if setup was successful. More...
 
std::string m_DefaultAgencyID
 A std::string containing the default agency id to use in parsing if one is not provided. More...
 
std::string m_DefaultAuthor
 A std::string containing the default author to use in parsing if one is not provided. More...
 

Detailed Description

glass fileInput class

The glass fileInput class is a class encapsulating the file input logic. The fileInput class handles reading data from disk, and sending the data to glasscore via the associator class.

fileInput inherits from the glass3::input::Input class.

Constructor & Destructor Documentation

glass3::fileInput::fileInput ( )

fileInput constructor

The constructor for the fileInput class. Initializes members to default values.

glass3::fileInput::fileInput ( const std::shared_ptr< const json::Object > &  config)
explicit

fileInput advanced constructor

The advanced constructor for the fileInput class. Initializes members to default values. Calls setup to configure the class Starts the work thread

Parameters
config- A json::Object pointer to the configuration to use
glass3::fileInput::~fileInput ( )

fileInput destructor

The destructor for the fileInput class. Stops the work thread

Member Function Documentation

void glass3::fileInput::cleanupFile ( std::string  filename,
bool  move,
std::string  destinationdir 
)
protected

cleanup file function

The function that moves the file identified by filename to the destination directory, or deletes it if move is false

Parameters
filename- A std::string containing the file to clean up
move- A boolean flag indicating whether to move or delete the file
destinationdir- A std::string containing the directory to move the file to, if desired.
void glass3::fileInput::clear ( )
overridevirtual

output clear function

The clear function for the output class. Clears all configuration.

Reimplemented from glass3::input::Input.

std::string glass3::fileInput::fetchRawData ( std::string *  pOutType)
overrideprotectedvirtual

get input data string and type

A function (overridden from glass3::input) that that retrieves the next data message and type from an input source

Parameters
pOutType- A pointer to a std::string used to pass out the type of the data
Returns
returns a std::string containing the input data message

Implements glass3::input::Input.

const std::string glass3::fileInput::getArchiveDir ( )

Function to retrieve the name of the archive directory.

This function retrieves the name of the archive directory

Returns
A std::string containing the archive directory name
const std::string glass3::fileInput::getFormat ( )

Function to retrieve the format type (extension)

This function retrieves the format type (extension)

Returns
A std::string containing the format type (extension)
const std::string glass3::fileInput::getInputDir ( )

Function to retrieve the name of the input directory.

This function retrieves the name of the input directory

Returns
A std::string containing the input directory name
int glass3::fileInput::getShutdownWait ( )

Function to retrieve the shutdown wait time.

This function retrieves the wait time before shutting down due to no data

Returns
Returns an integer value containing the shutdown wait in seconds
bool glass3::fileInput::getShutdownWhenNoData ( )

Function to retrieve whether to shutdown when no data.

This function retrieves the boolean flag indicating whether to shutdown when there is no data

Returns
A boolean flag indicating whether to shut down
void glass3::fileInput::setArchiveDir ( const std::string &  dir)

Function to set the name of the archive directory.

This function sets the name of of the archive directory

Parameters
dir= A std::string containing the archive directory to set
void glass3::fileInput::setFormat ( const std::string &  format)

Function to set the format type (extension)

This function sets the format type (extension)

Parameters
format= A std::string containing the format type
void glass3::fileInput::setInputDir ( const std::string &  dir)

Function to set the name of the input directory.

This function sets the name of of the input directory

Parameters
dir= A std::string containing the input directory to set
void glass3::fileInput::setShutdownWait ( int  waitTime)

Function to set the shutdown wait time.

This function sets the wait time before shutting down due to no data

Parameters
waitTime= An integer value containing the shutdown wait in seconds
void glass3::fileInput::setShutdownWhenNoData ( bool  shutdown)

Function to set whether to shutdown when no data.

This function sets the boolean flag indicating whether to shutdown when there is no data

Parameters
shutdown= A boolean flag indicating whether to shut down
bool glass3::fileInput::setup ( std::shared_ptr< const json::Object >  config)
overridevirtual

fileInput configuration function

The this function configures the fileInput class, and allocates the parsing objects and data queue.

Parameters
config- A pointer to a json::Object containing to the configuration to use
Returns
returns true if successful.

Reimplemented from glass3::input::Input.


The documentation for this class was generated from the following files: