1 #ifndef SZA_ARRAY_TRANSACTION_H
2 #define SZA_ARRAY_TRANSACTION_H
14 #include "carma/szaarrayutils/input.h"
25 static const unsigned DEV_NAME_MAX = 100;
26 static const unsigned SERIAL_NAME_MAX = 20;
27 static const unsigned LOCATION_NAME_MAX = 100;
28 static const unsigned WHO_NAME_MAX = 20;
29 static const unsigned PREFIX_LEN = 5;
44 void readCatalog(std::string dir, std::string file);
73 Location(std::string name) : name_(name) {};
80 class Location_eq :
public std::unary_function<Location, bool> {
83 explicit Location_eq(std::string name) : name_(name) {}
84 bool operator() (
const Location& location)
const {
85 return location.name_ == name_;
96 SerialNumber(std::string name) : name_(name) {};
107 bool operator() (
const SerialNumber& sn)
const {
108 return sn.name_ == name_;
121 std::list<SerialNumber*> serialNumbers_;
125 std::list<Location*> locations_;
127 Device(std::string name) : name_(name) {};
128 void addLocation(Location* location);
129 void addSerialNumber(SerialNumber* serialNumber);
132 Location* findLocation(std::string name);
133 SerialNumber* findSerialNumber(std::string name);
134 bool isValidLocation(std::string name);
135 bool isValidSerialNumber(std::string name);
142 class Device_eq :
public std::unary_function<Device, bool> {
145 explicit Device_eq(std::string name) : name_(name) {}
146 bool operator() (
const Device& device)
const {
147 return device.name_ == name_;
160 std::list<Device> devices_;
161 std::list<Location> locations_;
162 std::list<SerialNumber> serialNumbers_;
166 void readLocation(Device* device, InputStream* stream);
170 void readSerialNumber(Device* device, InputStream* stream);
174 Device* readDevice(InputStream* stream);
180 Device* findDevice(std::string name);
184 bool isValidDevice(std::string name);
188 bool isValidSerialNumber(std::string device, std::string serial);
192 bool isValidLocation(std::string device, std::string location);
198 Location* findLocation(std::string name);
202 SerialNumber* findSerialNumber(std::string name);
209 static int notSeparatorChar(
int c);
213 Device* addDevice(std::string name);
217 Location* addLocation(std::string name);
221 SerialNumber* addSerialNumber(std::string name);
230 #endif // End #ifndef SZA_ARRAY_TRANSACTION_H
virtual ~TransactionManager()
Destructor.
void printSerialNumbers()
Print known serialNumbers.
A predicate for testing if a Device matches a requested device.
void printDevices()
Print known devices.
A class for managing transactions.
void printLocations()
Print known locations.
A predicate for testing if a Location matches a requested location.
void clearCatalog()
Clear the catalog.
A predicate for testing if a SerialNumber matches a requested sn.
void readCatalog(std::string dir, std::string file)
Read a transaction catalog.
TransactionManager()
Constructor.
void printAll()
Print the tree of device->location/serialNumbers.