Adun  0.83
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AdunTrajectory.h
1 /*
2  Project: AdunCore
3 
4  Copyright (C) 2007 Michael Johnston & Jordi VillĂ --Freixa
5 
6  Author: Michael Johnston
7 
8  This application is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This application is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU General Public
19  License along with this library; if not, write to the Free
20  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
21  */
22 
23 #ifndef _AdTrajectory_H_
24 #define _AdTrajectory_H_
25 
26 #include <Foundation/Foundation.h>
28 #include <AdunKernel/AdunModelObject.h>
29 #include <AdunKernel/AdunDataMatrix.h>
30 #include <AdunKernel/AdunDataSet.h>
31 #include <AdunKernel/AdunSystem.h>
32 #include <AdunKernel/AdunSystemCollection.h>
33 #include <AdunKernel/AdunForceFieldCollection.h>
34 #include <AdunKernel/AdunInteractionSystem.h>
35 
43 typedef enum
44 {
49 }
51 
55 @protocol AdSimulationStorageReading <NSObject>
59 - (NSURL*) storagePath;
67 - (unsigned long long) sizeOfStore;
72 - (BOOL) isTemporary;
78 - (BOOL) isAccessible;
83 - (NSError*) accessError;
94 - (NSError*) dataError;
101 - (unsigned int) numberTrajectoryCheckpoints;
105 - (unsigned int) numberTopologyCheckpoints;
112 - (NSData*) trajectoryCheckpoint: (int) number;
120 - (NSData*) topologyCheckpoint: (int) number;
125 - (NSData*) energyData;
135 - (NSData*) systemData;
142 - (NSData*) frameData;
150 - (void) update;
151 
152 @end
153 
163 - (void) setEnergyData: (NSData*) data;
169 - (void) setFrameData: (NSData*) data;
175 - (void) setSystemData: (NSData*) data;
180 - (void) addTrajectoryCheckpoint: (NSData*) data;
187 - (void) removeTrajectoryCheckpoints: (int) number;
192 - (void) addTopologyCheckpoint: (NSData*) data;
199 - (void) removeTopologyCheckpoints: (int) number;
203 - (void) synchronizeStore;
210 - (BOOL) destroyStoredData;
215 - (void) setIsTemporary: (BOOL) value;
216 @end
217 
228 - (void) prepareForCheckpointRequestsWithRange: (NSRange) range stepSize: (unsigned int) stepSize;
235 @end
236 
299 {
300  BOOL checkDataStorageIdentification;
301  unsigned int numberEnergyCheckpoints;
302  AdDataSet* stateData;
303  id systemCollection;
304  id <AdSimulationStorageReading, AdTrajectoryCheckpointRequestPreparation> dataStorage;
305  id frames;
306 }
307 + (id) trajectoryFromLocation: (id) location;
308 + (id) trajectoryFromLocation: (id) location error: (NSError**) error;
314 - (id) initWithLocation: (id) location error: (NSError**) error;
318 - (NSURL*) location;
322 - (id) dataStorage;
327 - (AdDataSet*) energies;
332 - (AdSystemCollection*) systemCollection;
336 - (NSArray*) systems;
341 - (AdDataSet*) frames;
347 - (id) mementoForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number;
353 - (id) dataSourceForSystem: (id) system inTopologyCheckpoint: (unsigned int) number;
357 - (AdDataMatrix*) coordinatesForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number;
362 - (void) coordinatesForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number usingBuffer: (AdMatrix*) buffer;
375 - (BOOL) compareCheckpointsForSystem: (id) aSystem
376  inTrajectory: (AdTrajectory*) aTrajectory
377  toSystem: (id) ourSystem
378  range: (NSRange) range;
382 - (unsigned int) numberTrajectoryCheckpoints;
386 - (unsigned int) numberTopologyCheckpoints;
390 - (unsigned int) numberOfFrames;
395 - (unsigned int) frameForTopologyCheckpoint: (unsigned int) number;
400 - (unsigned int) frameForEnergyCheckpoint: (unsigned int) number;
405 - (unsigned int) frameForTrajectoryCheckpoint: (unsigned int) number;
410 - (id) lastRecordedDataSourceForSystem: (id) system inRange: (NSRange) aRange;
415 - (NSArray*) dataRecordedInFrame: (unsigned int) frame;
419 - (void) update;
420 @end
421 
422 
423 @protocol AdTrajectoryMethods
424 - (NSString*) location;
425 - (AdDataSet*) energies;
426 - (NSArray*) systems;
427 - (AdDataSet*) frames;
428 - (id) mementoForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number;
429 - (id) dataSourceForSystem: (id) system inTopologyCheckpoint: (unsigned int) number;
430 - (AdDataMatrix*) coordinatesForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number;
431 - (void) coordinatesForSystem: (id) system inTrajectoryCheckpoint: (unsigned int) number usingBuffer: (AdMatrix*) buffer;
432 - (unsigned int) numberTrajectoryCheckpoints;
433 - (unsigned int) numberTopologyCheckpoints;
434 - (unsigned int) numberOfFrames;
435 - (unsigned int) frameForTopologyCheckpoint: (unsigned int) number;
436 - (unsigned int) frameForEnergyCheckpoint: (unsigned int) number;
437 - (unsigned int) frameForTrajectoryCheckpoint: (unsigned int) number;
438 - (id) lastRecordedDataSourceForSystem: (id) system inRange: (NSRange) aRange;
439 - (NSArray*) dataRecordedInFrame: (unsigned int) frame;
440 - (void) update;
445 - (AdSystemCollection*) systemCollection;
446 @end
447 
513 @interface AdMutableTrajectory: NSObject <AdTrajectoryMethods>
514 {
515  BOOL needsUpdate;
516  BOOL frameOpen;
517  BOOL trajectoryCheckpoint;
518  BOOL topologyCheckpoint;
519  BOOL energyCheckpoint;
520  int lastFrame;
521  NSMutableData* trajectoryData;
522  NSMutableDictionary* energyData;
523  NSString* iterationHeader;
524  NSNumber* iterationValue;
525  NSMutableDictionary* topologyData;
526  AdForceFieldCollection* forceFieldCollection;
527  AdSystemCollection* systemCollection;
528  AdDataSet* stateData;
529  AdMutableDataMatrix* frames;
530  AdTrajectory* trajectoryReader;
531  id dataStorage;
532 }
533 + (id) trajectoryFromLocation: (NSString*) location;
540 + (id) trajectoryFromLocation: (NSString*) location error: (NSError**) error;
547 - (id) initWithLocation: (NSString*) path error: (NSError**) error;
566 - (id) initWithLocation: (id) path
567  systems: (AdSystemCollection*) aSystemCollection
568  forceFields: (AdForceFieldCollection*) aForceFieldCollection
569  iterationHeader: (NSString*) aString
570  error: (NSError**) error;
579 - (void) setForceFields: (AdForceFieldCollection*) aForceFieldCollection;
587 - (void) openFrame: (NSNumber*) iterationNumber;
591 - (BOOL) isOpenFrame;
596 - (void) closeFrame;
601 - (int) lastFrame;
605 - (unsigned int) lastEnergyCheckpoint;
609 - (unsigned int) lastTrajectoryCheckpoint;
613 - (unsigned int) lastTopologyCheckpoint;
617 - (NSNumber*) lastIterationNumber;
622 - (void) addTopologyCheckpoint;
626 - (void) addTopologyCheckpointForSystem: (id) aSystem;
632 - (void) addTrajectoryCheckpoint;
637 - (void) addEnergyCheckpoint;
643 - (void) rollBackToFrame: (unsigned int) value;
647 - (void) synchToStore;
652 - (id) dataStorage;
653 @end
654 
655 #endif