int main()
{
  typedef rt::node_allocator_lazy<int> inner_alloc_type;
  typedef std::list<int, inner_alloc_type> inner_list_type;

  typedef std::scoped_allocator_adaptor< rt::node_allocator_lazy<inner_list_type>
                                       , inner_alloc_type> outer_alloc_type;
  typedef std::list<inner_list_type, outer_alloc_type> outer_list_type;

  std::array<char, 2000> buffer1 = {{}};
  std::array<char, 2000> buffer2 = {{}};
  rt::node_alloc_header header1(buffer1);
  rt::node_alloc_header header2(buffer2);

  inner_alloc_type alloc1(&header1);
  rt::node_allocator_lazy<inner_list_type> alloc2(&header2);

  outer_alloc_type alloc(alloc2, alloc1);

  outer_list_type t1(alloc);

  t1.push_back({{5, 3, 7, 20}, alloc1});
  t1.push_back({{1, 44, 22, 8}, alloc1});

  rt::print(t1.front());
  rt::print(t1.back());
}
 //! <b>Requires</b>: node1 and node2 can't be header nodes
 //!  of two trees.
 //! 
 //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted
 //!   in the position node2 before the function. node2 will be inserted in the
 //!   position node1 had before the function.
 //! 
 //! <b>Complexity</b>: Logarithmic. 
 //! 
 //! <b>Throws</b>: Nothing.
 //! 
 //! <b>Note</b>: This function will break container ordering invariants if
 //!   node1 and node2 are not equivalent according to the ordering rules.
 //!
 //!Experimental function
 static void swap_nodes(node_ptr node1, node_ptr node2)
 {
    if(node1 == node2)
       return;
 
    node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2));
    swap_nodes(node1, header1, node2, header2);
 }
void		msh_header(void)
{
	int	i;

	i = 0;
	while (i < 7 * 6)
	{
		if (i % 7 < 4)
			header1(i / 7 * 4 + i % 7);
		else
			header2(i / 7 * 3 + i % 7 - 4);
		i++;
	}
	return ;
}
Exemple #4
0
int main(int argc, char** argv)
{
    try
    {
        nitf_Error e;

//        Foo<int>* foo = new Bar<int>();
//        delete foo;

        nitf_Field* cField = nitf_Field_construct(100, NITF_BCS_N, &e);
        nitf::Field field(cField);

        {
            nitf::Field field2(cField);
        }

        std::cout << field.isValid() << std::endl;


        nitf_BandInfo* cBandInfo = nitf_BandInfo_construct(&e);
        assert(cBandInfo);

        nitf::BandInfo info(cBandInfo);

        std::cout << (int)info.getNumLUTs() << std::endl;

        std::cout << "HERE!!!!!!!!!!!!!!!!!!!!" << std::endl;
        nitf::SubWindow sub;
        nitf::SubWindow sub2 = sub;
        sub.setNumRows(5);

        nitf::PixelSkip p(1, 1);
        sub.setDownSampler(p);
        sub.setDownSampler(p);
        sub.setDownSampler(p);
        sub.setDownSampler(p);

        nitf::PixelSkip p2(1, 1);
        sub.setDownSampler(p2);
        sub.setDownSampler(p);


        nitf_SubWindow* subw = nitf_SubWindow_construct(&e);
        nitf::SubWindow sub3(subw);
        std::cout << sub.getNumRows() <<  " == " << sub2.getNumRows() << std::endl;


        nitf::List list;
        nitf::List list2 = list;

        {
            nitf::FileHeader header;
            nitf::FileHeader header2(header.clone());
            //should be not equal
            std::cout << "Equal? " << (header == header2) << std::endl;
            nitf::FileHeader header3(header2);
            //these two should be equal
            std::cout << "Equal? " << (header3 == header2) << std::endl;
        }

        nitf::HashTable hash;

        nitf::Extensions extensions;
        {
            nitf::ImageSegment imageSeg;
            nitf::ImageSubheader imageSub;

            imageSeg.getSubheader().getImageId() = "Test Image";
            std::cout << imageSeg.getSubheader().getImageId().toString() << std::endl;
            nitf::Field f = imageSeg.getSubheader().getImageId();
            std::cout << f.toString() << std::endl;

            nitf::ImageSegment imageSeg2 = imageSeg.clone();
            nitf::ImageSubheader imageSub2(imageSub.clone());

            extensions = imageSub.getExtendedSection();
        }

        nitf::TextSegment tSeg;
        nitf::TextSubheader tSub;

        nitf::GraphicSegment gSeg;
        nitf::GraphicSubheader gSub;

        nitf::DESegment dSeg;
        nitf::DESubheader dSub;

        nitf::LabelSegment rSeg;
        nitf::LabelSubheader rSub;

        nitf::TRE tre("JITCID");
        //tre.print();
        std::cout << "HERE!!!!!" << std::endl;

        nitf::Reader reader;
        nitf::Writer writer;


        //open a file
        sys::OS os;
        std::vector< std::string > files;
        for (int i = 1; i < argc; ++i)
        {
            if (!os.exists(argv[i]))
                std::cout << "Error -> File does not exist: " << argv[i] << std::endl;
            else
                files.push_back(argv[i]);
        }

        for (std::vector< std::string >::iterator it = files.begin(); it != files.end(); ++it)
        {
            nitf::IOHandle handle(*it);
            nitf::Reader rdr;
            nitf::Record rec = rdr.read(handle);

            std::cout << "CODEWORDS: " << rec.getHeader().getSecurityGroup().getCodewords().toString() << std::endl;
            rec.getHeader().getSecurityGroup().getCodewords() = "TEST";
            std::cout << "CODEWORDS: " << rec.getHeader().getSecurityGroup().getCodewords().toString() << std::endl;
            nitf::FileSecurity security;
            rec.getHeader().setSecurityGroup(security);
            std::cout << "CODEWORDS: " << rec.getHeader().getSecurityGroup().getCodewords().toString() << std::endl;
            std::cout << "Num Images: " << rec.getImages().getSize() << std::endl;
        }

        nitf_SubWindow_destruct(&subw);
        nitf_Field_destruct(&cField);
        nitf_BandInfo_destruct(&cBandInfo);
    }
    catch(except::Exception& ex)
    {
        std::cerr << "ERROR: " << ex.getMessage() << std::endl;
        return 1;
    }

    return 0;
}
void mainChat(){
	string str,temp;
	int status;
	status=1; //0 if logout

	header2();
	while(status==1){
		cout << endl;
		kunci.lock();
		messageNotifier();
		cout << username << "> ";
		getline(cin >> ws,str);
		kunci.unlock();
		//logout
		if(str.compare("logout")==0){
			status=0;
			logout();
		}
		//message
		else if(str.substr(0,8).compare("message ")==0){
			temp = str.substr(8);
			sendMessage(temp);
		}
		//create group
		else if(str.substr(0,7).compare("create ")==0){
			temp = str.substr(7);
			groupCreate(temp);
		}
		//join group
		else if(str.substr(0,5).compare("join ")==0){
			temp = str.substr(5);
			groupJoin(temp);
		}
		//leave group
		else if(str.substr(0,6).compare("leave ")==0){
			temp = str.substr(6);
			groupLeave(temp);
		}
		//show chat history
		else if(str.substr(0,5).compare("show ")==0){
			temp = str.substr(5);
			readChat2(temp);
			deleteNotifSender(temp);
			//moveToBottom(..pathnya dimana..);
		}
		else if(str.compare("help")==0){
			header2();
		}
		//exit
		else if(str.compare("exit")==0){
			status=0;
			active = false;
			closeConnection();
			exit(0);
		}
		//empty input
		else if(str.compare("")==0){
			//do nothing
		}
		//wrong input
		else{
			cout <<"Unknown input, please type \'help\' for help." <<endl;
		}
	}
}
Exemple #6
0
/** Reads detector information from a .dat file, the file contains one line per detector
*  and its format is documented in "DETECTOR.DAT format" (more details in LoadDetectorInfo.h)
*  @param fName :: name and path of the data file to read
*  @throw invalid_argument if the detection delay time is different for different monitors
*  @throw FileError if there was a problem opening the file or its format
*  @throw MisMatch<int> if not very spectra is associated with exaltly one detector
*  @throw IndexError if there is a problem converting spectra indexes to spectra numbers, which would imply there is a problem with the workspace
*  @throw runtime_error if the SpectraDetectorMap had not been filled
*/
void LoadDetectorInfo::readDAT(const std::string& fName)
{
  g_log.information() << "Opening DAT file " << fName << std::endl;
  std::ifstream sFile(fName.c_str());
  if (!sFile)
  {
    throw Exception::FileError("Can't open file", fName);
  }
  // update the progress monitor and allow for user cancel
  progress(0.05);
  interruption_point();
 
  std::string str;
  // skip header line which contains something like <filename> generated by <prog>
  getline(sFile,str);
  g_log.debug() << "Reading " << fName << std::endl;
  g_log.information() << "Writing to the detector parameter map, only the first and last entries will be logged here\n";

  int detectorCount, numColumns;
  getline(sFile,str);
  std::istringstream header2(str);
  // header information is two numbers, the number of detectors, which we use but don't rely on, and the number of columns which we trust
  header2 >> detectorCount >> numColumns;
  if( detectorCount < 1 || numColumns != 14)
  {
    g_log.debug() << "Problem with the header information on the second line of the file, found: " << str << std::endl; 
    g_log.error() << name() << " requires that the input file has 14 columns and the number of detectors is positve\n";
    throw Exception::FileError("Incompatible file format found when reading line 2 in the input file", fName);
  }
 
  // skip title line
  getline(sFile,str);

  // will store all hte detector IDs that we get data for
  std::vector<detid_t> detectorList;
  detectorList.reserve(detectorCount);
  // stores the time offsets that the TOF X-values will be adjusted by at the end
  std::vector<float> offsets;
  offsets.reserve(detectorCount);
  float detectorOffset = UNSETOFFSET;
  bool differentOffsets = false;
  // used only for progress and logging
  std::vector<detid_t> missingDetectors;
  int count = 0, detectorProblemCount = 0;
  detectorInfo log;
  bool noneSet = true;
  // Now loop through lines, one for each detector or monitor. The latter are ignored.
  while( getline(sFile, str) )
  {
    if (str.empty() || str[0] == '#')
    {// comments and empty lines are allowed and ignored
      continue;
    }
    std::istringstream istr(str);
    
    detectorInfo readin;
    int code;
    float delta;
    // data for each detector in the file that we don't need
    float dump;

    // columns in the file, the detector ID and a code for the type of detector CODE = 3 (psd gas tube)
    istr >> readin.detID >> delta >> readin.l2 >> code >> readin.theta >> readin.phi;
    detectorList.push_back(readin.detID);
    offsets.push_back(delta);
    
    // check we have a supported code
    switch (code)
    {
      // these first two codes are detectors that we'll process, the code for this is below
      case PSD_GAS_TUBE : break;
      case NON_PSD_GAS_TUBE : break;

      // the following detectors codes specify little or no analysis
      case MONITOR_DEVICE :
        // throws invalid_argument if the detection delay time is different for different monitors
        noteMonitorOffset( delta, readin.detID);
        // skip the rest of this loop and move on to the next detector
        continue;

      // the detector is set to dummy, we won't report any error for this we'll just do nothing
      case DUMMY_DECT : continue;
      
      //we can't use data for detectors with other codes because we don't know the format, ignore the data and write to g_log.warning() once at the end
      default :
        detectorProblemCount ++;
        g_log.debug() << "Ignoring data for a detector with code " << code << std::endl;
        continue;
    }

    // gas filled detector specific code now until the end of this method
    
    // normally all the offsets are the same and things work faster, check for this
    if ( delta != detectorOffset )
    {// could mean different detectors have different offsets and we need to do things thoroughly
      if ( detectorOffset !=  UNSETOFFSET )
      {
        differentOffsets = true;
      }
      detectorOffset = delta;
    }

    //there are 10 uninteresting columns
    istr >> dump >> dump >> dump >> dump >> dump >> dump >> dump >> dump >> dump >> dump;
    // column names det_2   ,   det_3  , (assumes that code=3), the last column is not read
    istr >> readin.pressure >> readin.wallThick;
    try
    {
      setDetectorParams(readin, log);
      sometimesLogSuccess(log, noneSet);
    }
    catch (Exception::NotFoundError &)
    {// there are likely to be some detectors that we can't find in the instrument definition and we can't save parameters for these. We can't do anything about this just report the problem at the end
      missingDetectors.push_back(readin.detID);
      continue;
    }

    // report progress and check for a user cancel message at regualar intervals
    count ++;
    if ( count % INTERVAL == INTERVAL/2 )
    {
      progress(static_cast<double>(count)/(3*detectorCount));
      interruption_point();
    }
  }

  sometimesLogSuccess(log, noneSet = true);
  g_log.debug() << "Adjusting time of flight X-values by detector delay times" << std::endl;
  adjDelayTOFs(detectorOffset, differentOffsets, detectorList, offsets);
  
  if ( detectorProblemCount > 0 )
  {
    g_log.warning() << "Data for " << detectorProblemCount << " detectors that are neither monitors or psd gas tubes, the data have been ignored" << std::endl;
  }
  logErrorsFromRead(missingDetectors);
  g_log.debug() << "Successfully read DAT file " << fName << std::endl;
}