{"action":"created","issue":{"url":"https://api.github.com/repos/yap/YAP/issues/69","repository_url":"https://api.github.com/repos/yap/YAP","labels_url":"https://api.github.com/repos/yap/YAP/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/yap/YAP/issues/69/comments","events_url":"https://api.github.com/repos/yap/YAP/issues/69/events","html_url":"https://github.com/yap/YAP/issues/69","id":163149662,"number":69,"title":"Change input scheme for ParticleFactory","user":{"login":"greenwald","id":2571281,"avatar_url":"https://avatars.githubusercontent.com/u/2571281?v=3","gravatar_id":"","url":"https://api.github.com/users/greenwald","html_url":"https://github.com/greenwald","followers_url":"https://api.github.com/users/greenwald/followers","following_url":"https://api.github.com/users/greenwald/following{/other_user}","gists_url":"https://api.github.com/users/greenwald/gists{/gist_id}","starred_url":"https://api.github.com/users/greenwald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenwald/subscriptions","organizations_url":"https://api.github.com/users/greenwald/orgs","repos_url":"https://api.github.com/users/greenwald/repos","events_url":"https://api.github.com/users/greenwald/events{/privacy}","received_events_url":"https://api.github.com/users/greenwald/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"pdigiglio","id":5367334,"avatar_url":"https://avatars.githubusercontent.com/u/5367334?v=3","gravatar_id":"","url":"https://api.github.com/users/pdigiglio","html_url":"https://github.com/pdigiglio","followers_url":"https://api.github.com/users/pdigiglio/followers","following_url":"https://api.github.com/users/pdigiglio/following{/other_user}","gists_url":"https://api.github.com/users/pdigiglio/gists{/gist_id}","starred_url":"https://api.github.com/users/pdigiglio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdigiglio/subscriptions","organizations_url":"https://api.github.com/users/pdigiglio/orgs","repos_url":"https://api.github.com/users/pdigiglio/repos","events_url":"https://api.github.com/users/pdigiglio/events{/privacy}","received_events_url":"https://api.github.com/users/pdigiglio/received_events","type":"User","site_admin":false},"assignees":[{"login":"pdigiglio","id":5367334,"avatar_url":"https://avatars.githubusercontent.com/u/5367334?v=3","gravatar_id":"","url":"https://api.github.com/users/pdigiglio","html_url":"https://github.com/pdigiglio","followers_url":"https://api.github.com/users/pdigiglio/followers","following_url":"https://api.github.com/users/pdigiglio/following{/other_user}","gists_url":"https://api.github.com/users/pdigiglio/gists{/gist_id}","starred_url":"https://api.github.com/users/pdigiglio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdigiglio/subscriptions","organizations_url":"https://api.github.com/users/pdigiglio/orgs","repos_url":"https://api.github.com/users/pdigiglio/repos","events_url":"https://api.github.com/users/pdigiglio/events{/privacy}","received_events_url":"https://api.github.com/users/pdigiglio/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2016-06-30T12:08:13Z","updated_at":"2016-07-04T12:56:30Z","closed_at":null,"body":"Let's replace `ParticleFactory::readPDT(const std::string fname)` with something using `istream_iterator`.\r\n\r\nA rough first idea:\r\n\r\n* implement `ParticleFactory::insert(iterator pos, ParticleTableEntry)`\r\n* implement `istream_iterator` to read a full line of a file.\r\n* implement a function to convert that full line to a `ParticleTableEntry` for the PDT format.\r\n\r\nWe would like to fill the table with:\r\n```cpp\r\ntemplate <class line_reader>\r\nvoid fillTable(istream_iterator first, istream_iterator last, line_reader LR)\r\n{\r\n  std::transform(first, last, std::inserter(ParticleTable_, ParticleTable_.end()), LR);\r\n}\r\n```\r\n\r\n`line_read` should be an object that has a functor such that the object can be called on a `istream_iterator`, and produce a `ParticleTableEntry`"},"comment":{"url":"https://api.github.com/repos/yap/YAP/issues/comments/230284393","html_url":"https://github.com/yap/YAP/issues/69#issuecomment-230284393","issue_url":"https://api.github.com/repos/yap/YAP/issues/69","id":230284393,"user":{"login":"greenwald","id":2571281,"avatar_url":"https://avatars.githubusercontent.com/u/2571281?v=3","gravatar_id":"","url":"https://api.github.com/users/greenwald","html_url":"https://github.com/greenwald","followers_url":"https://api.github.com/users/greenwald/followers","following_url":"https://api.github.com/users/greenwald/following{/other_user}","gists_url":"https://api.github.com/users/greenwald/gists{/gist_id}","starred_url":"https://api.github.com/users/greenwald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenwald/subscriptions","organizations_url":"https://api.github.com/users/greenwald/orgs","repos_url":"https://api.github.com/users/greenwald/repos","events_url":"https://api.github.com/users/greenwald/events{/privacy}","received_events_url":"https://api.github.com/users/greenwald/received_events","type":"User","site_admin":false},"created_at":"2016-07-04T12:56:30Z","updated_at":"2016-07-04T12:56:30Z","body":"```cpp\r\ntemplate <class Iter>\r\nParticleFactory::ParticleFactory(Iter first, Iter last)\r\n{\r\n    std::copy(first, last, std::inserter(ParticleTable_, ParticleTable_.end()));\r\n}\r\n\r\nauto PF = ParticleFactory(yap::XXXIterator(file), yap::XXXIterator::end());\r\n```\r\n\r\nIn ParticeFactory add\r\n```cpp\r\nusing ParticleTableMap = std::map<int, ParticleTableEntry>;\r\n```\r\n\r\nSo: the iterators above must dereference to a `ParticleTableMap::value_type` and the increment operator must increment some internal structure of the iterator to state from which you can construct or read the next `ParticleTableEntry`.\r\n\r\nFor example, for PDL:\r\n* The `PDLIterator` would store an `istream_iterator` to a file inside it.\r\n* Dereferencing constructs a `ParticleTableEntry` from the point of the internal `istream_iterator`\r\n* Incrementing increments until the point starting the next entry (a line starting with `\"add\"`) or failing that, sets the iterator to the end.\r\n\r\nYou can also make a helper function, inside the file, say, for `PDLIterator`:\r\n```cpp\r\nParticleFactory read_pdl_file(std::string filename)\r\n{ return ParticleFactory(PDLIterator(fstream(filename)), PDLIterator::end()); }\r\n```"}}
{"actor":{"display_login":"greenwald"}}