Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
132:05cd37f7e007
Parent:
121:ee02790d00b7
Child:
135:2f4290590e51
--- a/vector.cpp	Tue Jul 21 20:03:35 2015 +0000
+++ b/vector.cpp	Tue Sep 01 17:21:11 2015 +0000
@@ -1,48 +1,58 @@
 #include "vector.h"
 
-Vector::Vector(){
-    this->objects = NULL;
-    this->elements = 0;
+Vector::Vector ()
+{
+    this -> objects = NULL;
+    this -> elements = 0;
 }
 
-Vector::~Vector(){
-    if( this->objects != NULL ) free( this->objects );  
+Vector::~Vector ()
+{
+    if ( this -> objects != NULL ) free ( this -> objects );  
 }
 
-void Vector::add( Object * e ){
-    if( e != NULL ){
-        this->objects = ( Object ** )realloc( this->objects, sizeof ( Object * ) * ++this->elements );
-        if ( this->objects == NULL ){
+void Vector::add ( Object * e )
+{
+    if ( e != NULL )
+    {
+        this -> objects = ( Object ** ) realloc ( this -> objects, sizeof ( Object * ) * ++( this -> elements ) );
+        if ( this -> objects == NULL )
+        {
             memory_is_over = true;
-            if( debug_memory ) debug_msg("Vector add fail");
-        }else{
-            this->objects[ this->elements - 1 ] = e;
+            if ( debug_memory ) vz_debug ( "Vector add fail" );
+        } else {
+            this -> objects [ this -> elements - 1 ] = e;
         }
     }
 }
 
-Object * Vector::get_element( int position ){
-    return( position > -1 && position < this->elements ) ? (Object *) * ( this->objects + position ) : NULL;
+Object * Vector::get_element ( int position )
+{
+    return ( position > -1 && position < this->elements ) ? ( Object * ) * ( this -> objects + position ) : NULL;
 }
 
-void Vector::remove_element( int position ){
-    if( debug_vector ) debug_msg( "Removing element %d", position );
-    if( position > -1 && position < this->elements ){
-        if( position == 0 && this->elements == 1 ) {
-            this->elements = 0;
-            free( this->objects );
-            this->objects = NULL;
-        }else{
-            this->objects[ position ] = this->objects[ --this->elements ];
-            this->objects = ( Object ** )realloc( this->objects, sizeof ( Object * ) * this->elements );
-            if( this->objects == NULL ) memory_is_over = true;
-            if( debug_memory ) debug_msg("Resize Vector fail");
+void Vector::remove_element ( int position )
+{
+    if ( debug_vector ) vz_debug ( "Removing element %d", position );
+    if ( position > -1 && position < this -> elements )
+    {
+        if ( position == 0 && this -> elements == 1 )
+        {
+            this -> elements = 0;
+            free ( this -> objects );
+            this -> objects = NULL;
+        } else {
+            this -> objects [ position ] = this -> objects[ -- ( this -> elements ) ];
+            this -> objects = ( Object ** ) realloc ( this -> objects, sizeof ( Object * ) * this -> elements );
+            if ( this -> objects == NULL ) memory_is_over = true;
+            if ( debug_memory ) vz_debug ( "Resize Vector fail" );
         }
     }
-    if( debug_vector ) debug_msg( "Removed" );
+    if ( debug_vector ) vz_debug ( "Removed" );
 }
 
-int Vector::find_element( Object * e ){
+int Vector::find_element ( Object * e )
+{
     if( e != NULL )
     {
         for( int i = 0; i < this->elements; i++ )
@@ -55,25 +65,26 @@
     }
 }
 
-int Vector::size( void ){ return this->elements; }
+int Vector::size ( void ) { return this -> elements; }
 
 int Vector::print_yourself ( void )
 {   
-    send_msg ("");
-    send_msg ("Elements :: %d ( %p )", this->elements, &( this->elements ) );   
-    send_msg ("Values ::\r\n");
+    vz_printf ("\r\n");
+    vz_printf ("Elements :: %d ( %p )", this -> elements, &( this->elements ) );   
+    vz_printf ("Values ::\r\n");
     
-    if( this->elements == 0 )
+    if ( this -> elements == 0 )
     {
-        send_msg ("Objects :: %p", this->objects );
+        vz_printf ( "Objects :: %p", this -> objects );
     }
         else
     {
-        for( register int i = 0; i < this->elements; i++ )
+        for ( register int i = 0; i < this -> elements; i++ )
         {
-            send_msg ("[ %i ] :: %p", i, ( this->objects +  i ) );
+            vz_printf ("[ %i ] :: %p", i, ( this -> objects +  i ) );
         }
     }
-    send_msg ("");
-    return ( sizeof( Vector ) );
+    vz_printf ("\r\n");
+    
+    return ( sizeof ( Vector ) );
 }
\ No newline at end of file