NGL@1.0.0-beta.7 Home Manual Reference Source Gallery

src/parser/parser-registry.js

  1. /**
  2. * @file Parser Registry
  3. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  4. * @private
  5. */
  6.  
  7. import Registry from '../utils/registry.js'
  8.  
  9. class ParserRegistry extends Registry {
  10. constructor () {
  11. super('parser')
  12. }
  13.  
  14. __hasObjName (key, objName) {
  15. const parser = this.get(key)
  16. return parser && parser.prototype.__objName === objName
  17. }
  18.  
  19. isTrajectory (key) {
  20. return this.__hasObjName(key, 'frames')
  21. }
  22.  
  23. isStructure (key) {
  24. return this.__hasObjName(key, 'structure')
  25. }
  26.  
  27. isVolume (key) {
  28. return this.__hasObjName(key, 'volume')
  29. }
  30.  
  31. isSurface (key) {
  32. return this.__hasObjName(key, 'surface')
  33. }
  34.  
  35. isBinary (key) {
  36. const parser = this.get(key)
  37. return parser && parser.prototype.isBinary
  38. }
  39.  
  40. isXml (key) {
  41. const parser = this.get(key)
  42. return parser && parser.prototype.isXml
  43. }
  44.  
  45. isJson (key) {
  46. const parser = this.get(key)
  47. return parser && parser.prototype.isJson
  48. }
  49.  
  50. getTrajectoryExtensions () {
  51. return this.names.filter(name => this.isTrajectory(name))
  52. }
  53.  
  54. getStructureExtensions () {
  55. return this.names.filter(name => this.isStructure(name))
  56. }
  57.  
  58. getVolumeExtensions () {
  59. return this.names.filter(name => this.isVolume(name))
  60. }
  61.  
  62. getSurfaceExtensions () {
  63. return this.names.filter(name => this.isSurface(name))
  64. }
  65. }
  66.  
  67. export default ParserRegistry