Schnek
literature.hpp
1 /*
2  * literature.hpp
3  *
4  * Created on: 13 Nov 2012
5  * Author: Holger Schmitz
6  * Email: holger@notjustphysics.com
7  *
8  * Copyright 2012 Holger Schmitz
9  *
10  * This file is part of Schnek.
11  *
12  * Schnek is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * Schnek is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Schnek. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef SCHNEK_LITERATURE_HPP_
28 #define SCHNEK_LITERATURE_HPP_
29 
30 #include "../util/singleton.hpp"
31 
32 #include <boost/tuple/tuple.hpp>
33 
34 #include <string>
35 #include <iostream>
36 #include <set>
37 #include <map>
38 
39 namespace schnek {
40 
42 {
43  public:
44  typedef enum {article, book, booklet, inbook, incollection,
45  inproceedings, manual, mastersthesis, misc, phdthesis,
46  proceedings, techreport, unpublished } PublicationType;
47 private:
48  // All the information needed for a BibTex entry.
49  // Descriptions of the fields are taken from Wikipedia
50  std::string address; // Publisher's address (usually just the city, but can be the full address for lesser-known publishers)
51  std::string annote; // An annotation for annotated bibliography styles (not typical)
52  std::string author; // The name(s) of the author(s) (in the case of more than one author, separated by and)
53  std::string booktitle; // The title of the book, if only part of it is being cited
54  std::string chapter; // The chapter number
55  std::string crossref; // The key of the cross-referenced entry
56  std::string edition; // The edition of a book, long form (such as "first" or "second")
57  std::string editor; // The name(s) of the editor(s)
58  std::string eprint; // A specification of an electronic publication, often a preprint or a technical report
59  std::string howpublished; // How it was published, if the publishing method is nonstandard
60  std::string institution; // The institution that was involved in the publishing, but not necessarily the publisher
61  std::string journal; // The journal or magazine the work was published in
62  std::string key; // A hidden field used for specifying or overriding the alphabetical order of entries (when the "author" and "editor" fields are missing). Note that this is very different from the citation key that is used to cite or cross-reference the entry.
63  std::string month; // The month of publication (or, if unpublished, the month of creation)
64  std::string note; // Miscellaneous extra information
65  std::string number; // The "(issue) number" of a journal, magazine, or tech-report, if applicable. (Most publications have a "volume", but no "number" field.)
66  std::string organization; // The conference sponsor
67  std::string pages; // Page numbers, separated either by commas or double-hyphens.
68  std::string publisher; // The publisher's name
69  std::string school; // The school where the thesis was written
70  std::string series; // The series of books the book was published in (e.g. "The Hardy Boys" or "Lecture Notes in Computer Science")
71  std::string title; // The title of the work
72  std::string type; // The field overriding the default type of publication (e.g. "Research Note" for techreport, "{PhD} dissertation" for phdthesis, "Section" for inbook/incollection)
73  std::string url; // The WWW address
74  std::string doi; // The DOI address
75  std::string volume; // The volume of a journal or multi-volume book
76  std::string year; // The year of publication (or, if unpublished, the year of creation)
77 
78  std::string bibKey;
79  PublicationType publType;
80  public:
82  LiteratureReference(std::string bibKey_) : bibKey(bibKey_) {}
83 
85  address(ref.address),
86  annote(ref.annote),
87  author(ref.author),
88  booktitle(ref.booktitle),
89  chapter(ref.chapter),
90  crossref(ref.crossref),
91  edition(ref.edition),
92  editor(ref.editor),
93  eprint(ref.eprint),
94  howpublished(ref.howpublished),
95  institution(ref.institution),
96  journal(ref.journal),
97  key(ref.key),
98  month(ref.month),
99  note(ref.note),
100  number(ref.number),
101  organization(ref.organization),
102  pages(ref.pages),
103  publisher(ref.publisher),
104  school(ref.school),
105  series(ref.series),
106  title(ref.title),
107  type(ref.type),
108  url(ref.url),
109  doi(ref.doi),
110  volume(ref.volume),
111  year(ref.year),
112  bibKey(ref.bibKey),
113  publType(ref.publType)
114  {}
115 
116  LiteratureReference &operator=(const LiteratureReference &ref)
117  {
118  address = ref.address;
119  annote = ref.annote;
120  author = ref.author;
121  booktitle = ref.booktitle;
122  chapter = ref.chapter;
123  crossref = ref.crossref;
124  edition = ref.edition;
125  editor = ref.editor;
126  eprint = ref.eprint;
127  howpublished = ref.howpublished;
128  institution = ref.institution;
129  journal = ref.journal;
130  key = ref.key;
131  month = ref.month;
132  note = ref.note;
133  number = ref.number;
134  organization = ref.organization;
135  pages = ref.pages;
136  publisher = ref.publisher;
137  school = ref.school;
138  series = ref.series;
139  title = ref.title;
140  type = ref.type;
141  url = ref.url;
142  doi = ref.doi;
143  volume = ref.volume;
144  year = ref.year;
145  bibKey = ref.bibKey;
146  publType = ref.publType;
147 
148  return *this;
149  }
150 
151  std::string getPublicationTypeString() const;
152 
153  PublicationType getPublicationType() const
154  {
155  return publType;
156  }
157 
158  std::string getAddress() const
159  {
160  return address;
161  }
162 
163  std::string getAnnote() const
164  {
165  return annote;
166  }
167 
168  std::string getAuthor() const
169  {
170  return author;
171  }
172 
173  std::string getBooktitle() const
174  {
175  return booktitle;
176  }
177 
178  std::string getChapter() const
179  {
180  return chapter;
181  }
182 
183  std::string getCrossref() const
184  {
185  return crossref;
186  }
187 
188  std::string getEdition() const
189  {
190  return edition;
191  }
192 
193  std::string getEditor() const
194  {
195  return editor;
196  }
197 
198  std::string getEprint() const
199  {
200  return eprint;
201  }
202 
203  std::string getHowpublished() const
204  {
205  return howpublished;
206  }
207 
208  std::string getInstitution() const
209  {
210  return institution;
211  }
212 
213  std::string getJournal() const
214  {
215  return journal;
216  }
217 
218  std::string getKey() const
219  {
220  return key;
221  }
222 
223  std::string getMonth() const
224  {
225  return month;
226  }
227 
228  std::string getNote() const
229  {
230  return note;
231  }
232 
233  std::string getNumber() const
234  {
235  return number;
236  }
237 
238  std::string getOrganization() const
239  {
240  return organization;
241  }
242 
243  std::string getPages() const
244  {
245  return pages;
246  }
247 
248  std::string getPublisher() const
249  {
250  return publisher;
251  }
252 
253  std::string getSchool() const
254  {
255  return school;
256  }
257 
258  std::string getSeries() const
259  {
260  return series;
261  }
262 
263  std::string getTitle() const
264  {
265  return title;
266  }
267 
268  std::string getType() const
269  {
270  return type;
271  }
272 
273  std::string getUrl() const
274  {
275  return url;
276  }
277 
278  std::string getDoi() const
279  {
280  return doi;
281  }
282 
283  std::string getVolume() const
284  {
285  return volume;
286  }
287 
288  std::string getYear() const
289  {
290  return year;
291  }
292 
293  virtual std::string getBibKey() const
294  {
295  return bibKey;
296  }
297 
298  void setPublicationType(PublicationType publType)
299  {
300  this->publType = publType;
301  }
302 
303  void setAddress(std::string address)
304  {
305  this->address = address;
306  }
307 
308  void setAnnote(std::string annote)
309  {
310  this->annote = annote;
311  }
312 
313  void setAuthor(std::string author)
314  {
315  this->author = author;
316  }
317 
318  void setBooktitle(std::string booktitle)
319  {
320  this->booktitle = booktitle;
321  }
322 
323  void setChapter(std::string chapter)
324  {
325  this->chapter = chapter;
326  }
327 
328  void setCrossref(std::string crossref)
329  {
330  this->crossref = crossref;
331  }
332 
333  void setEdition(std::string edition)
334  {
335  this->edition = edition;
336  }
337 
338  void setEditor(std::string editor)
339  {
340  this->editor = editor;
341  }
342 
343  void setEprint(std::string eprint)
344  {
345  this->eprint = eprint;
346  }
347 
348  void setHowpublished(std::string howpublished)
349  {
350  this->howpublished = howpublished;
351  }
352 
353  void setInstitution(std::string institution)
354  {
355  this->institution = institution;
356  }
357 
358  void setJournal(std::string journal)
359  {
360  this->journal = journal;
361  }
362 
363  void setKey(std::string key)
364  {
365  this->key = key;
366  }
367 
368  void setMonth(std::string month)
369  {
370  this->month = month;
371  }
372 
373  void setNote(std::string note)
374  {
375  this->note = note;
376  }
377 
378  void setNumber(std::string number)
379  {
380  this->number = number;
381  }
382 
383  void setOrganization(std::string organization)
384  {
385  this->organization = organization;
386  }
387 
388  void setPages(std::string pages)
389  {
390  this->pages = pages;
391  }
392 
393  void setPublisher(std::string publisher)
394  {
395  this->publisher = publisher;
396  }
397 
398  void setSchool(std::string school)
399  {
400  this->school = school;
401  }
402 
403  void setSeries(std::string series)
404  {
405  this->series = series;
406  }
407 
408  void setTitle(std::string title)
409  {
410  this->title = title;
411  }
412 
413  void setType(std::string type)
414  {
415  this->type = type;
416  }
417 
418  void setUrl(std::string url)
419  {
420  this->url = url;
421  }
422 
423  void setDoi(std::string doi)
424  {
425  this->doi = doi;
426  }
427 
428  void setVolume(std::string volume)
429  {
430  this->volume = volume;
431  }
432 
433  void setYear(std::string year)
434  {
435  this->year = year;
436  }
437 
438 };
439 
440 
442 {
443  public:
444  LiteratureArticle(std::string bibKey, std::string author, std::string title, std::string journal, std::string year,
445  std::string volume = "", std::string pages = "", std::string number = "", std::string month = "",
446  std::string note = "", std::string key = "")
447  : LiteratureReference(bibKey)
448  {
449  setPublicationType(article);
450 
451  setAuthor(author);
452  setTitle(title);
453  setJournal(journal);
454  setYear(year);
455  setVolume(volume);
456  setNumber(number);
457  setPages(pages);
458  setMonth(month);
459  setNote(note);
460  setKey(key);
461 
462  }
463 };
464 
466 {
467  public:
468  LiteratureBook(std::string bibKey, std::string author, std::string editor, std::string title, std::string publisher, std::string year,
469  std::string volume = "", std::string number = "", std::string series = "", std::string address = "",
470  std::string edition = "", std::string month = "", std::string note = "", std::string key = "")
471  : LiteratureReference(bibKey)
472  {
473  setPublicationType(book);
474 
475  setAuthor(author);
476  setEditor(editor);
477  setTitle(title);
478  setPublisher(publisher);
479  setYear(year);
480  setVolume(volume);
481  setNumber(number);
482  setSeries(series);
483  setAddress(address);
484  setEdition(edition);
485  setMonth(month);
486  setNote(note);
487  setKey(key);
488  }
489 };
490 
491 
493 {
494  public:
495  LiteratureBooklet(std::string bibKey, std::string title,
496  std::string author = "", std::string howpublished = "", std::string address = "",
497  std::string month = "", std::string year= "", std::string note = "", std::string key = "")
498  : LiteratureReference(bibKey)
499  {
500  setPublicationType(booklet);
501 
502  setTitle(title);
503  setAuthor(author);
504  setHowpublished(howpublished);
505  setAddress(address);
506  setMonth(month);
507  setYear(year);
508  setNote(note);
509  setKey(key);
510  }
511 };
512 
513 
515 {
516  public:
517  LiteratureInBook(std::string bibKey, std::string author, std::string editor, std::string title, std::string chapter,
518  std::string pages, std::string publisher, std::string year,
519  std::string volume = "", std::string number = "", std::string series = "", std::string type = "",
520  std::string address = "", std::string edition = "", std::string month = "", std::string note = "",
521  std::string key = "")
522  : LiteratureReference(bibKey)
523  {
524  setPublicationType(inbook);
525 
526  setAuthor(author);
527  setEditor(editor);
528  setTitle(title);
529  setChapter(chapter);
530  setPages(pages);
531  setPublisher(publisher);
532  setYear(year);
533  setVolume(volume);
534  setNumber(number);
535  setSeries(series);
536  setType(type);
537  setAddress(address);
538  setEdition(edition);
539  setMonth(month);
540  setNote(note);
541  setKey(key);
542  }
543 };
544 
546 {
547  public:
548  LiteratureInCollection(std::string bibKey, std::string author, std::string title, std::string booktitle,
549  std::string publisher, std::string year,
550  std::string editor = "", std::string volume = "", std::string number = "", std::string series = "",
551  std::string type = "", std::string chapter = "", std::string pages = "", std::string address = "",
552  std::string edition = "", std::string month = "", std::string note = "", std::string key = "")
553  : LiteratureReference(bibKey)
554  {
555  setPublicationType(incollection);
556 
557  setAuthor(author);
558  setTitle(title);
559  setBooktitle(booktitle);
560  setPublisher(publisher);
561  setYear(year);
562  setEditor(editor);
563  setVolume(volume);
564  setNumber(number);
565  setSeries(series);
566  setType(type);
567  setChapter(chapter);
568  setPages(pages);
569  setAddress(address);
570  setEdition(edition);
571  setMonth(month);
572  setNote(note);
573  setKey(key);
574  }
575 };
576 
577 
579 {
580  public:
581  LiteratureInProceedings(std::string bibKey, std::string author, std::string title, std::string booktitle, std::string year,
582  std::string editor = "", std::string volume = "", std::string number = "", std::string series = "",
583  std::string pages = "", std::string address = "", std::string month = "", std::string organization = "",
584  std::string publisher = "", std::string note = "", std::string key = "")
585  : LiteratureReference(bibKey)
586  {
587  setPublicationType(inproceedings);
588 
589  setAuthor(author);
590  setTitle(title);
591  setBooktitle(booktitle);
592  setYear(year);
593  setEditor(editor);
594  setVolume(volume);
595  setNumber(number);
596  setSeries(series);
597  setPages(pages);
598  setAddress(address);
599  setMonth(month);
600  setEdition(organization);
601  setPublisher(publisher);
602  setNote(note);
603  setKey(key);
604  }
605 };
606 
607 
609 {
610  public:
611  LiteratureManual(std::string bibKey, std::string title,
612  std::string author = "", std::string organization = "", std::string address = "", std::string edition = "",
613  std::string year = "", std::string publisher = "", std::string note = "", std::string key = "")
614  : LiteratureReference(bibKey)
615  {
616  setPublicationType(manual);
617 
618  setTitle(title);
619  setAuthor(author);
620  setEdition(organization);
621  setAddress(address);
622  setEdition(edition);
623  setYear(year);
624  setPublisher(publisher);
625  setNote(note);
626  setKey(key);
627  }
628 };
629 
631 {
632  public:
633  LiteratureMastersThesis(std::string bibKey, std::string author, std::string title, std::string school, std::string year,
634  std::string type = "", std::string address = "", std::string month = "",
635  std::string note = "", std::string key = "")
636  : LiteratureReference(bibKey)
637  {
638  setPublicationType(mastersthesis);
639 
640  setAuthor(author);
641  setTitle(title);
642  setEdition(school);
643  setYear(year);
644  setType(type);
645  setAddress(address);
646  setMonth(month);
647  setNote(note);
648  setKey(key);
649  }
650 };
651 
652 
653 
655 {
656  public:
657  LiteratureMisc(std::string bibKey, std::string author, std::string title, std::string howpublished = "",
658  std::string month = "", std::string year= "", std::string note = "", std::string key = "")
659  : LiteratureReference(bibKey)
660  {
661  setPublicationType(misc);
662 
663  setAuthor(author);
664  setTitle(title);
665  setHowpublished(howpublished);
666  setMonth(month);
667  setYear(year);
668  setNote(note);
669  setKey(key);
670  }
671 };
672 
673 
675 {
676  public:
677  LiteraturePhdThesis(std::string bibKey, std::string author, std::string title, std::string school, std::string year,
678  std::string type = "", std::string address = "", std::string month = "",
679  std::string note = "", std::string key = "")
680  : LiteratureReference(bibKey)
681  {
682  setPublicationType(phdthesis);
683 
684  setAuthor(author);
685  setTitle(title);
686  setEdition(school);
687  setYear(year);
688  setType(type);
689  setAddress(address);
690  setMonth(month);
691  setNote(note);
692  setKey(key);
693  }
694 };
695 
696 
698 {
699  public:
700  LiteratureProceedings(std::string bibKey, std::string title, std::string year,
701  std::string editor = "", std::string volume = "", std::string number = "", std::string series = "",
702  std::string address = "", std::string month = "", std::string organization = "",
703  std::string publisher = "", std::string note = "", std::string key = "")
704  : LiteratureReference(bibKey)
705  {
706  setPublicationType(proceedings);
707 
708  setTitle(title);
709  setYear(year);
710  setEditor(editor);
711  setVolume(volume);
712  setNumber(number);
713  setSeries(series);
714  setAddress(address);
715  setMonth(month);
716  setEdition(organization);
717  setPublisher(publisher);
718  setNote(note);
719  setKey(key);
720  }
721 };
722 
724 {
725  public:
726  LiteratureTechReport(std::string bibKey, std::string author, std::string title, std::string institution, std::string year,
727  std::string type = "", std::string number = "", std::string address = "", std::string month = "",
728  std::string note = "", std::string key = "")
729  : LiteratureReference(bibKey)
730  {
731  setPublicationType(techreport);
732 
733  setAuthor(author);
734  setTitle(title);
735  setInstitution(institution);
736  setYear(year);
737  setType(type);
738  setNumber(number);
739  setAddress(address);
740  setMonth(month);
741  setNote(note);
742  setKey(key);
743  }
744 };
745 
747 {
748  public:
749  LiteratureUnpublished(std::string bibKey, std::string author, std::string title, std::string note, std::string year,
750  std::string month = "", std::string key = "")
751  : LiteratureReference(bibKey)
752  {
753  setPublicationType(unpublished);
754 
755  setAuthor(author);
756  setTitle(title);
757  setNote(note);
758  setYear(year);
759  setMonth(month);
760  setKey(key);
761  }
762 };
763 
764 class LiteratureManager : public Singleton<LiteratureManager>
765 {
766  private:
767  friend class CreateUsingNew<LiteratureManager>;
768  typedef std::set<std::string> Descriptions;
769  typedef std::pair<Descriptions, LiteratureReference> LitRecord;
770  typedef std::map<std::string, LitRecord> Records;
771  Records records;
772  std::string title;
773  std::string subtitle;
774 
775  LiteratureManager();
776  public:
777  void addReference(std::string description, const LiteratureReference &reference);
778  void writeInformation(std::ostream &, std::string bibfile);
779  void writeBibTex(std::ostream &);
780 
781  const std::string& getTitle() const
782  {
783  return title;
784  }
785 
786  void setTitle(const std::string& title)
787  {
788  this->title = title;
789  }
790 
791  const std::string& getSubtitle() const
792  {
793  return subtitle;
794  }
795 
796  void setSubtitle(const std::string& subtitle)
797  {
798  this->subtitle = subtitle;
799  }
800 };
801 
802 std::ostream& operator<<(std::ostream&, const LiteratureReference &);
803 
804 } // namespace schnek
805 
806 #endif /* SCHNEK_LITERATURE_HPP_ */
Definition: literature.hpp:608
Definition: literature.hpp:723
Definition: literature.hpp:514
Definition: literature.hpp:441
Definition: singleton.hpp:80
Definition: literature.hpp:674
Definition: singleton.hpp:42
Definition: literature.hpp:492
Definition: literature.hpp:41
Definition: literature.hpp:697
Definition: algo.hpp:30
Definition: literature.hpp:578
Definition: literature.hpp:630
Definition: literature.hpp:465
Definition: literature.hpp:654
Definition: literature.hpp:746
Definition: literature.hpp:764
Definition: literature.hpp:545