int WaitFrames::GetFrames(Agent* pAgent) const { if (this->m_frames_var) { BEHAVIAC_ASSERT(this->m_frames_var); TProperty<int>* pP = (TProperty<int>*)this->m_frames_var; uint64_t frames = pP->GetValue(pAgent); return (frames == ((uint64_t) - 1) ? -1 : (int)frames); } else if (this->m_frames_method) { Agent* pParent = Agent::GetInstance(pAgent, this->m_frames_method->GetInstanceNameString()); BEHAVIAC_ASSERT(pParent); this->m_frames_method->run(pParent, pAgent); int frames = this->m_frames_method->GetReturnValue<int>(pParent); return frames; } return 0; }
int WaitFramesState::GetFrames(Agent* pAgent) const { if (this->m_frames_var) { BEHAVIAC_ASSERT(this->m_frames_var); TProperty<int>* pP = (TProperty<int>*)this->m_frames_var; uint64_t frames = pP->GetValue(pAgent); return (frames == ((uint64_t)-1) ? -1 : (int)frames); } else if (this->m_frames_method) { //ParentType pt = this->m_frames_method->GetParentType(); Agent* pParent = pAgent; /*if (pt == PT_INSTANCE) {*/ pParent = Agent::GetInstance(this->m_frames_method->GetInstanceNameString(), pParent->GetContextId()); BEHAVIAC_ASSERT(pParent); /*}*/ this->m_frames_method->run(pParent, pAgent); int frames = this->m_frames_method->GetReturnValue<int>(pParent); return frames; } return 0; }
float Wait::GetTime(Agent* pAgent) const { if (this->m_time_var) { BEHAVIAC_ASSERT(this->m_time_var); TProperty<float>* pP = (TProperty<float>*)this->m_time_var; return pP->GetValue(pAgent); } return 0; }
int DecoratorWeight::GetWeight(behaviac::Agent* pAgent) const { if (this->m_weight_var) { BEHAVIAC_ASSERT(this->m_weight_var); TProperty<int>* pP = (TProperty<int>*)this->m_weight_var; uint64_t count = pP->GetValue(pAgent); return (count == ((uint64_t) - 1) ? -1 : (int)count); } return 0; }
int DecoratorCount::GetCount(Agent* pAgent) const { if (this->m_count_var) { BEHAVIAC_ASSERT(this->m_count_var); TProperty<int>* pP = (TProperty<int>*)this->m_count_var; uint64_t count = pP->GetValue(pAgent); return (count == ((uint64_t) - 1) ? -1 : (int)count); } return 0; }
/** * MakeClone is responsible for creating a clone of this IProperty * derived class and returning it as part of the Prototype and Instance * system. The value of the Property will also be copied into the clone. * @return pointer to the IProperty derived class clone that was created */ IProperty* MakeClone() { TProperty<TYPE>* anProperty = new(std::nothrow) TProperty<TYPE>(GetID()); // Make sure new didn't fail before setting the value for this property if(NULL != anProperty) { anProperty->SetValue(mValue); } // Return cloned anProperty or NULL if none was created return anProperty; }
bool TViewCodeGenerator::CreateHeader(bool ReallyWriteInFile) { /* FHeaderCodeFile = new TCodeFile(APath,ClassName,"h"); FBodyCodeFile = new TCodeFile(APath,ClassName,"cpp"); FMakeFileCodeFile = new TCodeFile(APath,"makefile",NULL); */ TCodeLine *FHeaderLine = new TCodeLine(FHeaderCodeFile); FHeaderLine->Copyrights(); TProperty *AProperty = FViewComponent->FPropertyList->GetProperty(PROP_NAME); AProperty->AddCodeFile(FHeaderCodeFile); TCodeLine *FHeaderLine2 = new TCodeLine(FHeaderCodeFile); // AProperty->AddCodeLine(FHeaderLine2); FHeaderLine2->AddString("#ifndef __"); FHeaderLine2->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); // FHeaderLine2->AddProperty(AProperty); FHeaderLine2->AddString("_H__ \n"); TCodeLine *FHeaderLine3 = new TCodeLine(FHeaderCodeFile); // AProperty->AddCodeLine(FHeaderLine3); FHeaderLine3->AddString("#define __"); FHeaderLine3->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); // FHeaderLine3->AddProperty(AProperty); FHeaderLine3->AddString("_H__ \n"); TCodeLine *FHeaderLine4 = new TCodeLine(FHeaderCodeFile); FHeaderLine4->AddString("#include <View.h>\n"); TCodeLine *FHeaderLine5 = new TCodeLine(FHeaderCodeFile); FHeaderLine5->AddString("class "); FHeaderLine5->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); // AProperty->AddCodeLine(FHeaderLine5); // FHeaderLine5->AddProperty(AProperty); FHeaderLine5->AddString(": public BView\n"); TCodeLine *FHeaderLine6 = new TCodeLine(FHeaderCodeFile); FHeaderLine6->AddString("{\n"); TCodeLine *FHeaderLine7 = new TCodeLine(FHeaderCodeFile); FHeaderLine7->AddString("\tpublic:\n"); TCodeLine *FHeaderLine8 = new TCodeLine(FHeaderCodeFile); FHeaderLine8->AddString("\t\t"); FHeaderLine8->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); // AProperty->AddCodeLine(FHeaderLine8); // FHeaderLine8->AddProperty(AProperty); FHeaderLine8->AddString("(BRect AFrame);\n"); TCodeLine *FHeaderLine9 = new TCodeLine(FHeaderCodeFile); FHeaderLine9->AddString("\t\t~"); FHeaderLine9->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); // AProperty->AddCodeLine(FHeaderLine9); // FHeaderLine9->AddProperty(AProperty); FHeaderLine9->AddString("(void);\n"); TCodeLine *FHeaderLine10 = new TCodeLine(FHeaderCodeFile); FHeaderLine10->AddString("\t\tvoid MessageReceived(BMessage *message);\n"); TCodeLine *FHeaderLine11 = new TCodeLine(FHeaderCodeFile); FHeaderLine11->AddString("\t\tvoid AttachedToWindow(void);\n"); TCodeLine *FHeaderLine12 = new TCodeLine(FHeaderCodeFile); FHeaderLine12->AddString("};\n"); TCodeLine *FHeaderLine13 = new TCodeLine(FHeaderCodeFile); FHeaderLine13->AddString("#endif\n"); if (ReallyWriteInFile) { FHeaderLine13->AddLine(NULL,NULL,NULL,NULL); FHeaderLine12->AddLine(NULL,NULL,NULL,NULL); FHeaderLine11->AddLine(NULL,NULL,NULL,NULL); FHeaderLine10->AddLine(NULL,NULL,NULL,NULL); FHeaderLine9->AddLine(NULL,NULL,NULL,NULL); FHeaderLine8->AddLine(NULL,NULL,NULL,NULL); FHeaderLine7->AddLine(NULL,NULL,NULL,NULL); FHeaderLine6->AddLine(NULL,NULL,NULL,NULL); FHeaderLine5->AddLine(NULL,NULL,NULL,NULL); FHeaderLine4->AddLine(NULL,NULL,NULL,NULL); FHeaderLine3->AddLine(NULL,NULL,NULL,NULL); FHeaderLine2->AddLine(NULL,NULL,NULL,NULL); FHeaderLine->AddLine(NULL,NULL,NULL,NULL); } return true; }
bool TViewCodeGenerator::CreateBody(bool ReallyWriteInFile) { TCodeLine *FBodyLine = new TCodeLine(FBodyCodeFile); FBodyLine->Copyrights(); TProperty *AProperty = FViewComponent->FPropertyList->GetProperty(PROP_NAME); AProperty->AddCodeFile(FBodyCodeFile); TCodeLine *FBodyLine2 = new TCodeLine(FBodyCodeFile); FBodyLine2->AddString("#include \""); FBodyLine2->AddProperty(FViewComponent,PROP_NAME,true,true); FBodyLine2->AddString(".h\"\n"); TCodeLine *FBodyLine3 = new TCodeLine(FBodyCodeFile); FBodyLine3->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); FBodyLine3->AddString("::"); FBodyLine3->AddProperty(FViewComponent,PROP_CLASSNAME,false,false); FBodyLine3->AddString("(BRect AFrame): BView(AFrame,NULL,"); FBodyLine3->AddProperty(FViewComponent,PROP_RESIZING_MODE,true,true); FBodyLine3->AddString(","); FBodyLine3->AddProperty(FViewComponent,PROP_FLAGS,true,true); FBodyLine3->AddString(")\n"); TCodeLine *FBodyLine4 = new TCodeLine(FBodyCodeFile); FBodyLine4->AddString("{\n"); TCodeLine *FBodyLine5 = new TCodeLine(FBodyCodeFile); FBodyLine5->AddString("}\n"); TCodeLine *FBodyLine6 = new TCodeLine(FBodyCodeFile); FBodyLine6->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); FBodyLine6->AddString("::~"); FBodyLine6->AddProperty(FViewComponent,PROP_CLASSNAME,false,false); FBodyLine6->AddString("(void)\n"); TCodeLine *FBodyLine7 = new TCodeLine(FBodyCodeFile); FBodyLine7->AddString("{\n"); TCodeLine *FBodyLine8 = new TCodeLine(FBodyCodeFile); FBodyLine8->AddString("}\n"); TCodeLine *FBodyLine9 = new TCodeLine(FBodyCodeFile); FBodyLine9->AddString("void "); FBodyLine9->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); FBodyLine9->AddString("::MessageReceived(BMessage *message)\n"); TCodeLine *FBodyLine10 = new TCodeLine(FBodyCodeFile); FBodyLine10->AddString("{\n"); TCodeLine *FBodyLine11 = new TCodeLine(FBodyCodeFile); FBodyLine11->AddString("\tswitch(message->what)\n"); TCodeLine *FBodyLine12 = new TCodeLine(FBodyCodeFile); FBodyLine12->AddString("\t{\n"); TCodeLine *FBodyLine13 = new TCodeLine(FBodyCodeFile); FBodyLine13->AddString("\t\tdefault :\n"); TCodeLine *FBodyLine14 = new TCodeLine(FBodyCodeFile); FBodyLine14->AddString("\t\t\tBView::MessageReceived(message);\n"); TCodeLine *FBodyLine15 = new TCodeLine(FBodyCodeFile); FBodyLine15->AddString("\t\t\tbreak;\n"); TCodeLine *FBodyLine16 = new TCodeLine(FBodyCodeFile); FBodyLine16->AddString("\t}\n"); TCodeLine *FBodyLine17 = new TCodeLine(FBodyCodeFile); FBodyLine17->AddString("}\n"); TCodeLine *FBodyLine18 = new TCodeLine(FBodyCodeFile); FBodyLine18->AddString("void "); FBodyLine18->AddProperty(FViewComponent,PROP_CLASSNAME,true,true); FBodyLine18->AddString("::AttachedToWindow(void)\n"); TCodeLine *FBodyLine19 = new TCodeLine(FBodyCodeFile); FBodyLine19->AddString("{\n"); TCodeLine *FBodyLine20 = new TCodeLine(FBodyCodeFile); FBodyLine20->AddString("\tBView::AttachedToWindow();\n"); TCodeLine *FBodyLine21 = new TCodeLine(FBodyCodeFile); FBodyLine21->AddString("}\n"); if (ReallyWriteInFile) { FBodyLine21->AddLine(NULL,NULL,NULL,NULL); FBodyLine20->AddLine(NULL,NULL,NULL,NULL); FBodyLine19->AddLine(NULL,NULL,NULL,NULL); FBodyLine18->AddLine(NULL,NULL,NULL,NULL); FBodyLine17->AddLine(NULL,NULL,NULL,NULL); FBodyLine16->AddLine(NULL,NULL,NULL,NULL); FBodyLine15->AddLine(NULL,NULL,NULL,NULL); FBodyLine14->AddLine(NULL,NULL,NULL,NULL); FBodyLine13->AddLine(NULL,NULL,NULL,NULL); FBodyLine12->AddLine(NULL,NULL,NULL,NULL); FBodyLine11->AddLine(NULL,NULL,NULL,NULL); FBodyLine10->AddLine(NULL,NULL,NULL,NULL); FBodyLine9->AddLine(NULL,NULL,NULL,NULL); FBodyLine8->AddLine(NULL,NULL,NULL,NULL); FBodyLine7->AddLine(NULL,NULL,NULL,NULL); FBodyLine6->AddLine(NULL,NULL,NULL,NULL); FBodyLine5->AddLine(NULL,NULL,NULL,NULL); FBodyLine4->AddLine(NULL,NULL,NULL,NULL); FBodyLine3->AddLine(NULL,NULL,NULL,NULL); FBodyLine2->AddLine(NULL,NULL,NULL,NULL); FBodyLine->AddLine(NULL,NULL,NULL,NULL); } return true; }