| 1 | mmeineke | 377 | #include <cstdlib> | 
| 2 |  |  | #include <cstdio> | 
| 3 |  |  | #include <cstring> | 
| 4 |  |  | #include <iostream> | 
| 5 |  |  |  | 
| 6 |  |  | #include "AtomStamp.hpp" | 
| 7 |  |  |  | 
| 8 |  |  | AtomStamp::AtomStamp(){ | 
| 9 |  |  |  | 
| 10 |  |  | unhandled = NULL; | 
| 11 |  |  | have_position = 0; | 
| 12 |  |  | have_orientation = 0; | 
| 13 |  |  | have_type = 0; | 
| 14 |  |  | have_extras = 0; | 
| 15 |  |  | } | 
| 16 |  |  |  | 
| 17 |  |  | AtomStamp::~AtomStamp(){ | 
| 18 |  |  |  | 
| 19 |  |  | if( unhandled != NULL ) delete unhandled; | 
| 20 |  |  | } | 
| 21 |  |  |  | 
| 22 |  |  | void AtomStamp::setPosition( double x, double y, double z ){ | 
| 23 |  |  |  | 
| 24 |  |  | pos[0] = x; | 
| 25 |  |  | pos[1] = y; | 
| 26 |  |  | pos[2] = z; | 
| 27 |  |  |  | 
| 28 |  |  | have_position = 1; | 
| 29 |  |  | } | 
| 30 |  |  |  | 
| 31 |  |  | void AtomStamp::setOrientation( double x, double y, double z ){ | 
| 32 |  |  |  | 
| 33 |  |  | ornt[0] = x; | 
| 34 |  |  | ornt[1] = y; | 
| 35 |  |  | ornt[2] = z; | 
| 36 |  |  |  | 
| 37 |  |  | have_orientation = 1; | 
| 38 |  |  | } | 
| 39 |  |  |  | 
| 40 |  |  | char* AtomStamp::assignString( char* lhs, char* rhs ){ | 
| 41 |  |  |  | 
| 42 |  |  | if( !strcmp( lhs, "type" ) ){ | 
| 43 |  |  | strcpy( type, rhs ); | 
| 44 |  |  | have_type = 1; | 
| 45 |  |  | } | 
| 46 |  |  | else{ | 
| 47 |  |  | if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); | 
| 48 |  |  | else unhandled->add( lhs, rhs ); | 
| 49 |  |  | have_extras = 1; | 
| 50 |  |  | } | 
| 51 |  |  | return NULL; | 
| 52 |  |  | } | 
| 53 |  |  |  | 
| 54 |  |  | char* AtomStamp::assignDouble( char* lhs, double rhs ){ | 
| 55 |  |  |  | 
| 56 |  |  | if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); | 
| 57 |  |  | else unhandled->add( lhs, rhs ); | 
| 58 |  |  | have_extras = 1; | 
| 59 |  |  | return NULL; | 
| 60 |  |  | } | 
| 61 |  |  |  | 
| 62 |  |  | char* AtomStamp::assignInt( char* lhs, int rhs ){ | 
| 63 |  |  |  | 
| 64 |  |  | if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); | 
| 65 |  |  | else unhandled->add( lhs, rhs ); | 
| 66 |  |  | have_extras = 1; | 
| 67 |  |  | return NULL; | 
| 68 |  |  | } | 
| 69 |  |  |  | 
| 70 |  |  | char* AtomStamp::checkMe( void ){ | 
| 71 |  |  |  | 
| 72 |  |  | if( !have_type ){ | 
| 73 |  |  | return strdup( "AtomStamp error. Atom was untyped." ); | 
| 74 |  |  | } | 
| 75 |  |  | return NULL; | 
| 76 |  |  | } |