/* * Test.cpp * Author: rryan */ #include #include #include #include #include #include // Uthbook items #include "Uthbook.h" using namespace std; int main(int narg, char *argv[]) { // create shared memory uthCreateSharedMem(); // create 1D float histogram and data const char* title2 = "mkFakeData 1D Float Histogram"; int nBin2 = 100; float xMin2 = -6.0; float xMax2 = 12.0; // book 1D float histogram into shared memory uthBook1Shared(title2, nBin2, xMin2, xMax2); float data; // file contains an undermined number of integer values ifstream fin; // declare stream variable name fin.open("test_data.dat"); // open file fin >> data; // get first number from the file (priming the input statement) // You must attempt to read info prior to an eof( ) test. while (!fin.eof( )) { //if not at end of file, continue reading numbers uthFillShared(0, data, 0, 1); // cout<> data; //get next number from file } fin.close( ); //close file uthPrintShared(0); // // create 1D float histogram and data // const char* title3 = "RFake 1D Float Histogram"; // int nBin3 = 10; // float xMin3 = -6.0; // float xMax3 = 12.0; // //// book 1D float histogram into shared memory // uthBook1Shared(title3, nBin3, xMin3, xMax3); // uthFillShared(1, -6.0, 0, 1); // uthFillShared(1, -5.0, 0, 1); // uthFillShared(1, -4.0, 0, 1); // uthFillShared(1, -3.0, 0, 1); // uthFillShared(1, -2.0, 0, 1); // uthFillShared(1, -1.0, 0, 1); // uthFillShared(1, 0.0, 0, 1); // uthFillShared(1, 1.0, 0, 1); // uthFillShared(1, 2.0, 0, 1); // uthFillShared(1, 3.0, 0, 1); // uthFillShared(1, 4.0, 0, 1); // uthFillShared(1, 5.0, 0, 1); // uthFillShared(1, 6.0, 0, 1); // uthFillShared(1, 7.0, 0, 1); // uthFillShared(1, 8.0, 0, 1); // uthFillShared(1, 9.0, 0, 1); // uthFillShared(1, 10.0, 0, 1); // uthFillShared(1, 11.0, 0, 1); // uthFillShared(1, 12.0, 0, 1); // uthPrintShared(1); // waits until done cout << "enter letter to quit..." << endl; string dumb; cin >> dumb; /* * int shm_unlink(const char *name) * removes a shared memory object specified by name. If some * process is still using the shared memory segment associated * to name, the segment is not removed until all references * to it have been closed. Commonly, shm_unlink is called * right after a successful shm_create, in order to assure * the memory object will be freed as soon as it's no longer * used. */ // requesting the removal of the shm object -- shm_unlink() if (shm_unlink(shmPath) != 0) { perror("In shm_unlink()"); } }